Skip to content

Commit

Permalink
aws_instance: Update data source for throughput attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
rajivshah3 committed Dec 11, 2020
1 parent 0ac7018 commit c7f42b0
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
10 changes: 10 additions & 0 deletions aws/data_source_aws_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,11 @@ func dataSourceAwsInstance() *schema.Resource {
Computed: true,
},

"throughput": {
Type: schema.TypeInt,
Computed: true,
},

"volume_size": {
Type: schema.TypeInt,
Computed: true,
Expand Down Expand Up @@ -263,6 +268,11 @@ func dataSourceAwsInstance() *schema.Resource {
Computed: true,
},

"throughput": {
Type: schema.TypeInt,
Computed: true,
},

"volume_size": {
Type: schema.TypeInt,
Computed: true,
Expand Down
49 changes: 49 additions & 0 deletions aws/data_source_aws_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,30 @@ func TestAccAWSInstanceDataSource_gp2IopsDevice(t *testing.T) {
})
}

func TestAccAWSInstanceDataSource_gp3ThroughputDevice(t *testing.T) {
resourceName := "aws_instance.test"
datasourceName := "data.aws_instance.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccInstanceDataSourceConfig_gp3ThroughputDevice,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrPair(datasourceName, "ami", resourceName, "ami"),
resource.TestCheckResourceAttrPair(datasourceName, "instance_type", resourceName, "instance_type"),
resource.TestCheckResourceAttrPair(datasourceName, "root_block_device.#", resourceName, "root_block_device.#"),
resource.TestCheckResourceAttrPair(datasourceName, "root_block_device.0.volume_size", resourceName, "root_block_device.0.volume_size"),
resource.TestCheckResourceAttrPair(datasourceName, "root_block_device.0.volume_type", resourceName, "root_block_device.0.volume_type"),
resource.TestCheckResourceAttrPair(datasourceName, "root_block_device.0.device_name", resourceName, "root_block_device.0.device_name"),
resource.TestCheckResourceAttrPair(datasourceName, "root_block_device.0.throughput", resourceName, "root_block_device.0.throughput"),
),
},
},
})
}

func TestAccAWSInstanceDataSource_blockDevices(t *testing.T) {
resourceName := "aws_instance.test"
datasourceName := "data.aws_instance.test"
Expand Down Expand Up @@ -567,6 +591,24 @@ data "aws_instance" "test" {
}
`

// GP3ThroughputDevice
var testAccInstanceDataSourceConfig_gp3ThroughputDevice = testAccLatestAmazonLinuxHvmEbsAmiConfig() + `
resource "aws_instance" "test" {
ami = data.aws_ami.amzn-ami-minimal-hvm-ebs.id
instance_type = "t3.medium"
root_block_device {
volume_type = "gp3"
volume_size = 10
throughput = 300
}
}
data "aws_instance" "test" {
instance_id = aws_instance.test.id
}
`

// Block Device
var testAccInstanceDataSourceConfig_blockDevices = testAccLatestAmazonLinuxHvmEbsAmiConfig() + `
resource "aws_instance" "test" {
Expand Down Expand Up @@ -601,6 +643,13 @@ resource "aws_instance" "test" {
device_name = "/dev/sde"
virtual_name = "ephemeral0"
}
ebs_block_device {
device_name = "/device/sdf"
volume_size = 10
volume_type = "gp3"
throughput = 300
}
}
data "aws_instance" "test" {
Expand Down

0 comments on commit c7f42b0

Please sign in to comment.