热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Raceconditionexecutingplan

Thisissuewasoriginallyopenedbyashashicorp/terraform#18123.Itwasmigratedh

This issue was originally opened by as hashicorp/terraform#18123. It was migrated here as a result of the provider split. The original body of the issue is below.

I'm writing a plan to build out a full AWS environment, from the VPC up to the EC2 & RDS instances. When I execute

1
terraform plan

, I sometimes receive errors about resources not being ready, like so:

1
2
3
4
5
Error: Error running plan: 1 error(s) occurred:



* aws_nat_gateway.production: 1 error(s) occurred:



* aws_nat_gateway.production: Resource 'aws_subnet.public' not found for variable 'aws_subnet.public.4.id'

Running plan a second time may yield no errors or it might yield even more. This only seems to happen with regards to the aws_subnet section.

Terraform Version

Terraform v0.11.7

Terraform Configuration Files

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
hcl

data "aws_availability_zones" "available" {}



## Create the VPC

resource "aws_vpc" "production" {

  cidr_block                    = "172.28.0.0/16"

  enable_dns_support            = true

  enable_dns_hostnames          = true



  tags {

    Name                        = "Production"

  }

}



## Start setting up the subnets

### Public subnets

resource "aws_subnet" "public" {

  count                         = 6

  vpc_id                        = "${aws_vpc.production.id}"

  cidr_block                    = "${cidrsubnet(aws_vpc.production.cidr_block, 7, count.index)}"

  availability_zone             = "${data.aws_availability_zones.available.names[count.index]}"

  map_public_ip_on_launch       = true



  tags {

    Name                        = "${data.aws_availability_zones.available.names[count.index]}-Public"

  }

}



## Everyone needs a route

### Create the internet gateway for the public subnets

resource "aws_internet_gateway" "main" {

  vpc_id                        = "${aws_vpc.production.id}"



  tags {

    Name                        = "Production gateway"

  }

}



### Associate the internet gateway with the main routing table

resource "aws_default_route_table" "pubroute" {

  default_route_table_id        = "${aws_vpc.production.default_route_table_id}"



  route {

    cidr_block                  = "0.0.0.0/0"

    gateway_id                  = "${aws_internet_gateway.main.id}"

  }

}



### Bolt the public subnets explicitly onto the default route table

resource "aws_route_table_association" "publica" {

  route_table_id                = "${aws_default_route_table.pubroute.id}"

  subnet_id                     = "${aws_subnet.public.0.id}"

}



resource "aws_route_table_association" "publicb" {

  route_table_id                = "${aws_default_route_table.pubroute.id}"

  subnet_id                     = "${aws_subnet.public.1.id}"

}



resource "aws_route_table_association" "publicc" {

  route_table_id                = "${aws_default_route_table.pubroute.id}"

  subnet_id                     = "${aws_subnet.public.2.id}"

}



resource "aws_route_table_association" "publicd" {

  route_table_id                = "${aws_default_route_table.pubroute.id}"

  subnet_id                     = "${aws_subnet.public.3.id}"

}



resource "aws_route_table_association" "publice" {

  route_table_id                = "${aws_default_route_table.pubroute.id}"

  subnet_id                     = "${aws_subnet.public.4.id}"

}



resource "aws_route_table_association" "publicf" {

  route_table_id                = "${aws_default_route_table.pubroute.id}"

  subnet_id                     = "${aws_subnet.public.5.id}"

}


Debug Output


Crash Output

N/A

Expected Behavior

All resources should generate and the plan command should display what will be created.

Actual Behavior

Resources are intermittently claimed to not be found. Rarely the plan command will successfully complete.

Steps to Reproduce


  1. terraform init

  2. terraform plan

Additional Context

None.

该提问来源于开源项目:hashicorp/terraform-provider-aws

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.



If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!


   



推荐阅读
author-avatar
菜牛
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有