Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provider/aws: Set aws_vpc ipv6 for associated only #12899

Merged
merged 1 commit into from
Mar 23, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions builtin/providers/aws/resource_aws_vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}