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

Bug: Properly set DMS Replication Instance data source private/public IPs, VPC security group IDs #32551

Merged
merged 3 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions .changelog/32551.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
data-source/aws_dms_replication_instance: Fixed bug that caused `replication_instance_private_ips`, `replication_instance_public_ips`, and `vpc_security_group_ids` to always return `null`
```
27 changes: 19 additions & 8 deletions internal/service/dms/replication_instance_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,6 @@ func DataSourceReplicationInstance() *schema.Resource {
Type: schema.TypeInt,
Computed: true,
},
"allow_major_version_upgrade": {
Type: schema.TypeBool,
Computed: true,
},
"apply_immediately": {
Type: schema.TypeBool,
Computed: true,
},
"auto_minor_version_upgrade": {
Type: schema.TypeBool,
Computed: true,
Expand Down Expand Up @@ -130,6 +122,25 @@ func dataSourceReplicationInstanceRead(ctx context.Context, d *schema.ResourceDa
d.Set("replication_instance_class", instance.ReplicationInstanceClass)
d.Set("replication_instance_id", instance.ReplicationInstanceIdentifier)

if err := d.Set("replication_instance_private_ips", aws.StringValueSlice(instance.ReplicationInstancePrivateIpAddresses)); err != nil {
return create.DiagError(names.DMS, create.ErrActionReading, DSNameReplicationTask, d.Id(), err)
}

if err := d.Set("replication_instance_public_ips", aws.StringValueSlice(instance.ReplicationInstancePublicIpAddresses)); err != nil {
return create.DiagError(names.DMS, create.ErrActionReading, DSNameReplicationTask, d.Id(), err)
}

d.Set("replication_subnet_group_id", instance.ReplicationSubnetGroup.ReplicationSubnetGroupIdentifier)

vpc_security_group_ids := []string{}
for _, sg := range instance.VpcSecurityGroups {
vpc_security_group_ids = append(vpc_security_group_ids, aws.StringValue(sg.VpcSecurityGroupId))
}

if err := d.Set("vpc_security_group_ids", vpc_security_group_ids); err != nil {
return create.DiagError(names.DMS, create.ErrActionReading, DSNameReplicationTask, d.Id(), err)
}

tags, err := listTags(ctx, conn, aws.StringValue(instance.ReplicationInstanceArn))

if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ func TestAccDMSReplicationInstanceDataSource_basic(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckReplicationInstanceExists(ctx, dataSourceName),
resource.TestCheckResourceAttrPair(dataSourceName, "replication_instance_id", resourceName, "replication_instance_id"),
resource.TestCheckResourceAttrPair(dataSourceName, "replication_instance_arn", resourceName, "replication_instance_arn"),
resource.TestCheckResourceAttrPair(dataSourceName, "replication_instance_class", resourceName, "replication_instance_class"),
resource.TestCheckResourceAttrPair(dataSourceName, "replication_instance_private_ips.#", resourceName, "replication_instance_private_ips.#"),
resource.TestCheckResourceAttrPair(dataSourceName, "replication_instance_public_ips.#", resourceName, "replication_instance_public_ips.#"),
),
},
},
Expand Down
33 changes: 10 additions & 23 deletions website/docs/d/dms_replication_instance.html.markdown
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
subcategory: "DMS (Database Migration)"
layout: "aws"
page_title: "AWS: aws_dms_certificate"
page_title: "AWS: aws_dms_replication_instance"
description: |-
Terraform data source for managing an AWS DMS (Database Migration) Replication Instance.
---
Expand All @@ -22,36 +22,23 @@ data "aws_dms_replication_instance" "test" {

The following arguments are required:

* `replication_instance_id` - (Required) The replication instance identifier. This parameter is stored as a lowercase string.

- Must contain from 1 to 63 alphanumeric characters or hyphens.
- First character must be a letter.
- Cannot end with a hyphen
- Cannot contain two consecutive hyphens.
* `replication_instance_id` - (Required) The replication instance identifier.

## Attributes Reference

In addition to all arguments above, the following attributes are exported:

* `allocated_storage` - (Default: 50, Min: 5, Max: 6144) The amount of storage (in gigabytes) to be initially allocated for the replication instance.
* `allow_major_version_upgrade` - (Default: false) Indicates that major version upgrades are allowed.
* `apply_immediately` - (Default: false) Indicates whether the changes should be applied immediately or during the next maintenance window. Only used when updating an existing resource.
* `auto_minor_version_upgrade` - (Default: false) Indicates that minor engine upgrades will be applied automatically to the replication instance during the maintenance window.
* `allocated_storage` - The amount of storage (in gigabytes) to be initially allocated for the replication instance.
* `auto_minor_version_upgrade` - Indicates that minor engine upgrades will be applied automatically to the replication instance during the maintenance window.
* `availability_zone` - The EC2 Availability Zone that the replication instance will be created in.
* `engine_version` - The engine version number of the replication instance.
* `kms_key_arn` - The Amazon Resource Name (ARN) for the KMS key that will be used to encrypt the connection parameters. If you do not specify a value for `kms_key_arn`, then AWS DMS will use your default encryption key. AWS KMS creates the default encryption key for your AWS account. Your AWS account has a different default encryption key for each AWS region.
* `multi_az` - Specifies if the replication instance is a multi-az deployment. You cannot set the `availability_zone` parameter if the `multi_az` parameter is set to `true`.
* `kms_key_arn` - The Amazon Resource Name (ARN) for the KMS key used to encrypt the connection parameters.
* `multi_az` - Specifies if the replication instance is a multi-az deployment.
* `preferred_maintenance_window` - The weekly time range during which system maintenance can occur, in Universal Coordinated Time (UTC).

- Default: A 30-minute window selected at random from an 8-hour block of time per region, occurring on a random day of the week.
- Format: `ddd:hh24:mi-ddd:hh24:mi`
- Valid Days: `mon, tue, wed, thu, fri, sat, sun`
- Constraints: Minimum 30-minute window.

* `publicly_accessible` - (Default: false) Specifies the accessibility options for the replication instance. A value of true represents an instance with a public IP address. A value of false represents an instance with a private IP address.
* `publicly_accessible` - Specifies the accessibility options for the replication instance. A value of true represents an instance with a public IP address. A value of false represents an instance with a private IP address.
* `replication_instance_arn` - The Amazon Resource Name (ARN) of the replication instance.
* `replication_instance_class` - The compute and memory capacity of the replication instance as specified by the replication instance class. See [AWS DMS User Guide](https://docs.aws.amazon.com/dms/latest/userguide/CHAP_ReplicationInstance.Types.html) for available instance sizes and advice on which one to choose.
* `replication_instance_class` - The compute and memory capacity of the replication instance as specified by the replication instance class. See [AWS DMS User Guide](https://docs.aws.amazon.com/dms/latest/userguide/CHAP_ReplicationInstance.Types.html) for information on instance classes.
* `replication_instance_private_ips` - A list of the private IP addresses of the replication instance.
* `replication_instance_public_ips` - A list of the public IP addresses of the replication instance.
* `replication_subnet_group_id` - (Optional) A subnet group to associate with the replication instance.
* `vpc_security_group_ids` - (Optional) A list of VPC security group IDs to be used with the replication instance. The VPC security groups must work with the VPC containing the replication instance.
* `replication_subnet_group_id` - A subnet group to associate with the replication instance.
* `vpc_security_group_ids` - A set of VPC security group IDs that are used with the replication instance.
Loading