commit
ee24fce321
|
@ -55,6 +55,21 @@ func resource_aws_subnet_create(
|
|||
s.ID, err)
|
||||
}
|
||||
|
||||
var attr string
|
||||
|
||||
// Map public ip on launch must be set in another API call
|
||||
if attr = s.Attributes["map_public_ip_on_launch"]; attr == "true" {
|
||||
modifyOpts := &ec2.ModifySubnetAttribute{
|
||||
SubnetId: s.ID,
|
||||
MapPublicIpOnLaunch: true,
|
||||
}
|
||||
log.Printf("[DEBUG] Subnet modify attributes: %#v", modifyOpts)
|
||||
_, err := ec2conn.ModifySubnetAttribute(modifyOpts)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Error modify subnet attributes: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Update our attributes and return
|
||||
return resource_aws_subnet_update_state(s, subnetRaw.(*ec2.Subnet))
|
||||
}
|
||||
|
@ -125,9 +140,10 @@ func resource_aws_subnet_diff(
|
|||
meta interface{}) (*terraform.ResourceDiff, error) {
|
||||
b := &diff.ResourceBuilder{
|
||||
Attrs: map[string]diff.AttrType{
|
||||
"availability_zone": diff.AttrTypeCreate,
|
||||
"cidr_block": diff.AttrTypeCreate,
|
||||
"vpc_id": diff.AttrTypeCreate,
|
||||
"availability_zone": diff.AttrTypeCreate,
|
||||
"cidr_block": diff.AttrTypeCreate,
|
||||
"vpc_id": diff.AttrTypeCreate,
|
||||
"map_public_ip_on_launch": diff.AttrTypeCreate,
|
||||
},
|
||||
|
||||
ComputedAttrs: []string{
|
||||
|
@ -145,6 +161,10 @@ func resource_aws_subnet_update_state(
|
|||
s.Attributes["cidr_block"] = subnet.CidrBlock
|
||||
s.Attributes["vpc_id"] = subnet.VpcId
|
||||
|
||||
if subnet.MapPublicIpOnLaunch {
|
||||
s.Attributes["map_public_ip_on_launch"] = "true"
|
||||
}
|
||||
|
||||
// We belong to a VPC
|
||||
s.Dependencies = []terraform.ResourceDependency{
|
||||
terraform.ResourceDependency{ID: subnet.VpcId},
|
||||
|
|
|
@ -17,6 +17,10 @@ func TestAccAWSSubnet(t *testing.T) {
|
|||
return fmt.Errorf("bad cidr: %s", v.CidrBlock)
|
||||
}
|
||||
|
||||
if v.MapPublicIpOnLaunch != true {
|
||||
return fmt.Errorf("bad MapPublicIpOnLaunch: %s", v.MapPublicIpOnLaunch)
|
||||
}
|
||||
return fmt.Errorf("bad MapPublicIpOnLaunch: %s", v.MapPublicIpOnLaunch)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -104,5 +108,6 @@ resource "aws_vpc" "foo" {
|
|||
resource "aws_subnet" "foo" {
|
||||
cidr_block = "10.1.1.0/24"
|
||||
vpc_id = "${aws_vpc.foo.id}"
|
||||
map_public_ip_on_launch = true
|
||||
}
|
||||
`
|
||||
|
|
Loading…
Reference in New Issue