Skip to content

Commit

Permalink
Merge pull request #14599 from ewbankkit/b-aws_launch_template-data-s…
Browse files Browse the repository at this point in the history
…ource-mismatched-schema

d/aws_launch_template: Change 'network_interfaces.delete_on_termination' to TypeString, matching associated resource
  • Loading branch information
anGie44 authored Aug 12, 2020
2 parents c995a6f + 57c52d2 commit a720950
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
2 changes: 1 addition & 1 deletion aws/data_source_aws_launch_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func dataSourceAwsLaunchTemplate() *schema.Resource {
Computed: true,
},
"delete_on_termination": {
Type: schema.TypeBool,
Type: schema.TypeString,
Computed: true,
},
"description": {
Expand Down
51 changes: 51 additions & 0 deletions aws/data_source_aws_launch_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,41 @@ func TestAccAWSLaunchTemplateDataSource_associatePublicIPAddress(t *testing.T) {
})
}

func TestAccAWSLaunchTemplateDataSource_networkInterfaces_deleteOnTermination(t *testing.T) {
rName := acctest.RandomWithPrefix("tf-acc-test")
dataSourceName := "data.aws_launch_template.test"
resourceName := "aws_launch_template.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSLaunchTemplateDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSLaunchTemplateDataSourceConfigNetworkInterfacesDeleteOnTermination(rName, "true"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrPair(dataSourceName, "network_interfaces.#", resourceName, "network_interfaces.#"),
resource.TestCheckResourceAttrPair(dataSourceName, "network_interfaces.0.delete_on_termination", resourceName, "network_interfaces.0.delete_on_termination"),
),
},
{
Config: testAccAWSLaunchTemplateDataSourceConfigNetworkInterfacesDeleteOnTermination(rName, "false"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrPair(dataSourceName, "network_interfaces.#", resourceName, "network_interfaces.#"),
resource.TestCheckResourceAttrPair(dataSourceName, "network_interfaces.0.delete_on_termination", resourceName, "network_interfaces.0.delete_on_termination"),
),
},
{
Config: testAccAWSLaunchTemplateDataSourceConfigNetworkInterfacesDeleteOnTermination(rName, "null"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrPair(dataSourceName, "network_interfaces.#", resourceName, "network_interfaces.#"),
resource.TestCheckResourceAttrPair(dataSourceName, "network_interfaces.0.delete_on_termination", resourceName, "network_interfaces.0.delete_on_termination"),
),
},
},
})
}

func TestAccAWSLaunchTemplateDataSource_NonExistent(t *testing.T) {
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand Down Expand Up @@ -255,6 +290,22 @@ data "aws_launch_template" "test" {
`, rName, associatePublicIPAddress)
}

func testAccAWSLaunchTemplateDataSourceConfigNetworkInterfacesDeleteOnTermination(rName, deleteOnTermination string) string {
return fmt.Sprintf(`
resource "aws_launch_template" "test" {
name = %[1]q
network_interfaces {
delete_on_termination = %[2]s
}
}
data "aws_launch_template" "test" {
name = aws_launch_template.test.name
}
`, rName, deleteOnTermination)
}

const testAccAWSLaunchTemplateDataSourceConfig_NonExistent = `
data "aws_launch_template" "test" {
name = "tf-acc-test-nonexistent"
Expand Down

0 comments on commit a720950

Please sign in to comment.