diff --git a/builtin/providers/aws/resource_aws_db_instance.go b/builtin/providers/aws/resource_aws_db_instance.go index 9af762f48..e6eaeae1b 100644 --- a/builtin/providers/aws/resource_aws_db_instance.go +++ b/builtin/providers/aws/resource_aws_db_instance.go @@ -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{ @@ -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 { @@ -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)) } @@ -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 { @@ -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)) } @@ -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") @@ -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)) } diff --git a/website/source/docs/providers/aws/r/db_instance.html.markdown b/website/source/docs/providers/aws/r/db_instance.html.markdown index c25f345c1..6c813d9b1 100644 --- a/website/source/docs/providers/aws/r/db_instance.html.markdown +++ b/website/source/docs/providers/aws/r/db_instance.html.markdown @@ -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).