mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-09 15:43:53 -06:00
provider/aws: Set aws_vpc ipv6 for associated only (#12899)
Fixes: #12895 The AWS API returns both dissociated and associated IPv6 CIDRs. The UI only returns the associated. Therefore, the assumption was made that we would always take the 1st association in the set to use for state We now loop over the set and look for the associated IPv6 CIDR before using that in state ``` % make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSVpc_' ==> Checking that code complies with gofmt requirements... go generate $(go list ./... | grep -v /terraform/vendor/) 2017/03/20 21:21:02 Generated command/internal_plugin_list.go TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSVpc_ -timeout 120m === RUN TestAccAWSVpc_importBasic --- PASS: TestAccAWSVpc_importBasic (65.91s) === RUN TestAccAWSVpc_basic --- PASS: TestAccAWSVpc_basic (50.88s) === RUN TestAccAWSVpc_enableIpv6 --- PASS: TestAccAWSVpc_enableIpv6 (49.89s) === RUN TestAccAWSVpc_dedicatedTenancy --- PASS: TestAccAWSVpc_dedicatedTenancy (50.59s) === RUN TestAccAWSVpc_tags --- PASS: TestAccAWSVpc_tags (98.89s) === RUN TestAccAWSVpc_update --- PASS: TestAccAWSVpc_update (93.46s) === RUN TestAccAWSVpc_bothDnsOptionsSet --- PASS: TestAccAWSVpc_bothDnsOptionsSet (20.71s) === RUN TestAccAWSVpc_DisabledDnsSupport --- PASS: TestAccAWSVpc_DisabledDnsSupport (49.55s) === RUN TestAccAWSVpc_classiclinkOptionSet --- PASS: TestAccAWSVpc_classiclinkOptionSet (54.92s) PASS ok github.com/hashicorp/terraform/builtin/providers/aws 534.829s ```
This commit is contained in:
parent
a8ad684325
commit
bed23ffbee
@ -19,7 +19,7 @@ func resourceAwsVpc() *schema.Resource {
|
||||
Update: resourceAwsVpcUpdate,
|
||||
Delete: resourceAwsVpcDelete,
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
State: resourceAwsVpcInstanceImport,
|
||||
},
|
||||
|
||||
Schema: map[string]*schema.Schema{
|
||||
@ -174,12 +174,16 @@ func resourceAwsVpcRead(d *schema.ResourceData, meta interface{}) error {
|
||||
// Tags
|
||||
d.Set("tags", tagsToMap(vpc.Tags))
|
||||
|
||||
if vpc.Ipv6CidrBlockAssociationSet != nil {
|
||||
d.Set("assign_generated_ipv6_cidr_block", true)
|
||||
d.Set("ipv6_association_id", vpc.Ipv6CidrBlockAssociationSet[0].AssociationId)
|
||||
d.Set("ipv6_cidr_block", vpc.Ipv6CidrBlockAssociationSet[0].Ipv6CidrBlock)
|
||||
} else {
|
||||
d.Set("assign_generated_ipv6_cidr_block", false)
|
||||
for _, a := range vpc.Ipv6CidrBlockAssociationSet {
|
||||
if *a.Ipv6CidrBlockState.State == "associated" {
|
||||
d.Set("assign_generated_ipv6_cidr_block", true)
|
||||
d.Set("ipv6_association_id", a.AssociationId)
|
||||
d.Set("ipv6_cidr_block", a.Ipv6CidrBlock)
|
||||
} else {
|
||||
d.Set("assign_generated_ipv6_cidr_block", false)
|
||||
d.Set("ipv6_association_id", "") // we blank these out to remove old entries
|
||||
d.Set("ipv6_cidr_block", "")
|
||||
}
|
||||
}
|
||||
|
||||
// Attributes
|
||||
@ -481,3 +485,9 @@ func resourceAwsVpcSetDefaultRouteTable(conn *ec2.EC2, d *schema.ResourceData) e
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceAwsVpcInstanceImport(
|
||||
d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
|
||||
d.Set("assign_generated_ipv6_cidr_block", false)
|
||||
return []*schema.ResourceData{d}, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user