Skip to content

Commit

Permalink
provider/aws: aws_db_instance now defaults publicly_accessible to (
Browse files Browse the repository at this point in the history
…#7117)

false

Fixes #7035

A known issue in Terraform means that d.GetOk() on a bool which is false
will mean it doesn't get evaulated. Therefore, when people set
publicly_accessible to false, it will never get evaluated on the Create

We are going to make it default to false now
  • Loading branch information
stack72 authored Jun 10, 2016
1 parent 2d4c0be commit 5ecc8e3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
25 changes: 8 additions & 17 deletions builtin/providers/aws/resource_aws_db_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func resourceAwsDbInstance() *schema.Resource {
"publicly_accessible": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Computed: true,
Default: true,
},

"vpc_security_group_ids": &schema.Schema{
Expand Down Expand Up @@ -332,6 +332,7 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error
CopyTagsToSnapshot: aws.Bool(d.Get("copy_tags_to_snapshot").(bool)),
DBInstanceClass: aws.String(d.Get("instance_class").(string)),
DBInstanceIdentifier: aws.String(identifier),
PubliclyAccessible: aws.Bool(d.Get("publicly_accessible").(bool)),
Tags: tags,
}
if attr, ok := d.GetOk("iops"); ok {
Expand All @@ -350,10 +351,6 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error
opts.StorageType = aws.String(attr.(string))
}

if attr, ok := d.GetOk("publicly_accessible"); ok {
opts.PubliclyAccessible = aws.Bool(attr.(bool))
}

if attr, ok := d.GetOk("db_subnet_group_name"); ok {
opts.DBSubnetGroupName = aws.String(attr.(string))
}
Expand Down Expand Up @@ -381,8 +378,9 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error
DBInstanceIdentifier: aws.String(d.Get("identifier").(string)),
DBSnapshotIdentifier: aws.String(d.Get("snapshot_identifier").(string)),
AutoMinorVersionUpgrade: aws.Bool(d.Get("auto_minor_version_upgrade").(bool)),
Tags: tags,
CopyTagsToSnapshot: aws.Bool(d.Get("copy_tags_to_snapshot").(bool)),
PubliclyAccessible: aws.Bool(d.Get("publicly_accessible").(bool)),
Tags: tags,
CopyTagsToSnapshot: aws.Bool(d.Get("copy_tags_to_snapshot").(bool)),
}

if attr, ok := d.GetOk("availability_zone"); ok {
Expand Down Expand Up @@ -418,10 +416,6 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error
opts.Port = aws.Int64(int64(attr.(int)))
}

if attr, ok := d.GetOk("publicly_accessible"); ok {
opts.PubliclyAccessible = aws.Bool(attr.(bool))
}

if attr, ok := d.GetOk("tde_credential_arn"); ok {
opts.TdeCredentialArn = aws.String(attr.(string))
}
Expand Down Expand Up @@ -500,8 +494,9 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error
EngineVersion: aws.String(d.Get("engine_version").(string)),
StorageEncrypted: aws.Bool(d.Get("storage_encrypted").(bool)),
AutoMinorVersionUpgrade: aws.Bool(d.Get("auto_minor_version_upgrade").(bool)),
Tags: tags,
CopyTagsToSnapshot: aws.Bool(d.Get("copy_tags_to_snapshot").(bool)),
PubliclyAccessible: aws.Bool(d.Get("publicly_accessible").(bool)),
Tags: tags,
CopyTagsToSnapshot: aws.Bool(d.Get("copy_tags_to_snapshot").(bool)),
}

attr := d.Get("backup_retention_period")
Expand Down Expand Up @@ -565,10 +560,6 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error
opts.AvailabilityZone = aws.String(attr.(string))
}

if attr, ok := d.GetOk("publicly_accessible"); ok {
opts.PubliclyAccessible = aws.Bool(attr.(bool))
}

if attr, ok := d.GetOk("monitoring_role_arn"); ok {
opts.MonitoringRoleArn = aws.String(attr.(string))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ the final snapshot (if `final_snapshot_identifier` is specified). Default
See [RDS Maintenance Window docs](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/AdjustingTheMaintenanceWindow.html) for more.
* `multi_az` - (Optional) Specifies if the RDS instance is multi-AZ
* `port` - (Optional) The port on which the DB accepts connections.
* `publicly_accessible` - (Optional) Bool to control if instance is publicly accessible.
* `publicly_accessible` - (Optional) Bool to control if instance is publicly accessible. Defaults to `false`.
* `vpc_security_group_ids` - (Optional) List of VPC security groups to associate.
* `security_group_names` - (Optional/Deprecated) List of DB Security Groups to associate.
Only used for [DB Instances on the _EC2-Classic_ Platform](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_VPC.html#USER_VPC.FindDefaultVPC).
Expand Down

0 comments on commit 5ecc8e3

Please sign in to comment.