diff --git a/aws/data_source_aws_launch_template.go b/aws/data_source_aws_launch_template.go index 55d489ef6ff..5067248636e 100644 --- a/aws/data_source_aws_launch_template.go +++ b/aws/data_source_aws_launch_template.go @@ -244,7 +244,7 @@ func dataSourceAwsLaunchTemplate() *schema.Resource { Computed: true, }, "delete_on_termination": { - Type: schema.TypeBool, + Type: schema.TypeString, Computed: true, }, "description": { diff --git a/aws/data_source_aws_launch_template_test.go b/aws/data_source_aws_launch_template_test.go index 537a1779558..2dd893d74a6 100644 --- a/aws/data_source_aws_launch_template_test.go +++ b/aws/data_source_aws_launch_template_test.go @@ -160,6 +160,41 @@ func TestAccAWSLaunchTemplateDataSource_associatePublicIPAddress(t *testing.T) { }) } +func TestAccAWSLaunchTemplateDataSource_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: testAccAWSLaunchTemplateDataSourceConfig_deleteOnTermination(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: testAccAWSLaunchTemplateDataSourceConfig_deleteOnTermination(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: testAccAWSLaunchTemplateDataSourceConfig_deleteOnTermination(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) }, @@ -255,6 +290,22 @@ data "aws_launch_template" "test" { `, rName, associatePublicIPAddress) } +func testAccAWSLaunchTemplateDataSourceConfig_deleteOnTermination(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"