diff --git a/aws/resource_aws_kinesis_firehose_delivery_stream_test.go b/aws/resource_aws_kinesis_firehose_delivery_stream_test.go index b0e264bf242..ec27394140e 100644 --- a/aws/resource_aws_kinesis_firehose_delivery_stream_test.go +++ b/aws/resource_aws_kinesis_firehose_delivery_stream_test.go @@ -78,13 +78,14 @@ func testSweepKinesisFirehoseDeliveryStreams(region string) error { return nil } -func TestAccAWSKinesisFirehoseDeliveryStream_importBasic(t *testing.T) { - resName := "aws_kinesis_firehose_delivery_stream.test_stream" +func TestAccAWSKinesisFirehoseDeliveryStream_basic(t *testing.T) { + resourceName := "aws_kinesis_firehose_delivery_stream.test" rInt := acctest.RandInt() funcName := fmt.Sprintf("aws_kinesis_firehose_ds_import_%d", rInt) policyName := fmt.Sprintf("tf_acc_policy_%d", rInt) roleName := fmt.Sprintf("tf_acc_role_%d", rInt) + var stream firehose.DeliveryStreamDescription config := testAccFirehoseAWSLambdaConfigBasic(funcName, policyName, roleName) + fmt.Sprintf(testAccKinesisFirehoseDeliveryStreamConfig_extendedS3basic, @@ -97,21 +98,25 @@ func TestAccAWSKinesisFirehoseDeliveryStream_importBasic(t *testing.T) { Steps: []resource.TestStep{ { Config: config, + Check: resource.ComposeTestCheckFunc( + testAccCheckKinesisFirehoseDeliveryStreamExists(resourceName, &stream), + testAccCheckAWSKinesisFirehoseDeliveryStreamAttributes(&stream, nil, nil, nil, nil, nil), + ), }, { - ResourceName: resName, + ResourceName: resourceName, ImportState: true, ImportStateVerify: true, }, // Ensure we properly error on malformed import IDs { - ResourceName: resName, + ResourceName: resourceName, ImportState: true, ImportStateId: "just-a-name", ExpectError: regexp.MustCompile(`Expected ID in format`), }, { - ResourceName: resName, + ResourceName: resourceName, ImportState: true, ImportStateId: "arn:aws:firehose:us-east-1:123456789012:missing-slash", ExpectError: regexp.MustCompile(`Expected ID in format`), @@ -123,6 +128,7 @@ func TestAccAWSKinesisFirehoseDeliveryStream_importBasic(t *testing.T) { func TestAccAWSKinesisFirehoseDeliveryStream_s3basic(t *testing.T) { var stream firehose.DeliveryStreamDescription ri := acctest.RandInt() + resourceName := "aws_kinesis_firehose_delivery_stream.test" config := fmt.Sprintf(testAccKinesisFirehoseDeliveryStreamConfig_s3basic, ri, ri, ri, ri) @@ -134,7 +140,7 @@ func TestAccAWSKinesisFirehoseDeliveryStream_s3basic(t *testing.T) { { Config: config, Check: resource.ComposeTestCheckFunc( - testAccCheckKinesisFirehoseDeliveryStreamExists("aws_kinesis_firehose_delivery_stream.test_stream", &stream), + testAccCheckKinesisFirehoseDeliveryStreamExists(resourceName, &stream), testAccCheckAWSKinesisFirehoseDeliveryStreamAttributes(&stream, nil, nil, nil, nil, nil), ), }, @@ -148,6 +154,7 @@ func TestAccAWSKinesisFirehoseDeliveryStream_s3basicWithSSE(t *testing.T) { rName := fmt.Sprintf("terraform-kinesis-firehose-basictest-%d", rInt) config := fmt.Sprintf(testAccKinesisFirehoseDeliveryStreamConfig_s3basic, rInt, rInt, rInt, rInt) + resourceName := "aws_kinesis_firehose_delivery_stream.test" resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -157,19 +164,19 @@ func TestAccAWSKinesisFirehoseDeliveryStream_s3basicWithSSE(t *testing.T) { { Config: testAccKinesisFirehoseDeliveryStreamConfig_s3basicWithSSE(rName, rInt, true), Check: resource.ComposeTestCheckFunc( - testAccCheckKinesisFirehoseDeliveryStreamExists("aws_kinesis_firehose_delivery_stream.test_stream", &stream), + testAccCheckKinesisFirehoseDeliveryStreamExists(resourceName, &stream), testAccCheckAWSKinesisFirehoseDeliveryStreamAttributes(&stream, nil, nil, nil, nil, nil), - resource.TestCheckResourceAttr("aws_kinesis_firehose_delivery_stream.test_stream", "server_side_encryption.#", "1"), - resource.TestCheckResourceAttr("aws_kinesis_firehose_delivery_stream.test_stream", "server_side_encryption.0.enabled", "true"), + resource.TestCheckResourceAttr(resourceName, "server_side_encryption.#", "1"), + resource.TestCheckResourceAttr(resourceName, "server_side_encryption.0.enabled", "true"), ), }, { Config: testAccKinesisFirehoseDeliveryStreamConfig_s3basicWithSSE(rName, rInt, false), Check: resource.ComposeTestCheckFunc( - testAccCheckKinesisFirehoseDeliveryStreamExists("aws_kinesis_firehose_delivery_stream.test_stream", &stream), + testAccCheckKinesisFirehoseDeliveryStreamExists(resourceName, &stream), testAccCheckAWSKinesisFirehoseDeliveryStreamAttributes(&stream, nil, nil, nil, nil, nil), - resource.TestCheckResourceAttr("aws_kinesis_firehose_delivery_stream.test_stream", "server_side_encryption.#", "1"), - resource.TestCheckResourceAttr("aws_kinesis_firehose_delivery_stream.test_stream", "server_side_encryption.0.enabled", "false"), + resource.TestCheckResourceAttr(resourceName, "server_side_encryption.#", "1"), + resource.TestCheckResourceAttr(resourceName, "server_side_encryption.0.enabled", "false"), ), }, { @@ -179,10 +186,10 @@ func TestAccAWSKinesisFirehoseDeliveryStream_s3basicWithSSE(t *testing.T) { { Config: testAccKinesisFirehoseDeliveryStreamConfig_s3basicWithSSE(rName, rInt, true), Check: resource.ComposeTestCheckFunc( - testAccCheckKinesisFirehoseDeliveryStreamExists("aws_kinesis_firehose_delivery_stream.test_stream", &stream), + testAccCheckKinesisFirehoseDeliveryStreamExists(resourceName, &stream), testAccCheckAWSKinesisFirehoseDeliveryStreamAttributes(&stream, nil, nil, nil, nil, nil), - resource.TestCheckResourceAttr("aws_kinesis_firehose_delivery_stream.test_stream", "server_side_encryption.#", "1"), - resource.TestCheckResourceAttr("aws_kinesis_firehose_delivery_stream.test_stream", "server_side_encryption.0.enabled", "true"), + resource.TestCheckResourceAttr(resourceName, "server_side_encryption.#", "1"), + resource.TestCheckResourceAttr(resourceName, "server_side_encryption.0.enabled", "true"), ), }, }, @@ -195,6 +202,7 @@ func TestAccAWSKinesisFirehoseDeliveryStream_s3basicWithTags(t *testing.T) { rName := fmt.Sprintf("terraform-kinesis-firehose-basictest-%d", rInt) config := fmt.Sprintf(testAccKinesisFirehoseDeliveryStreamConfig_s3basic, rInt, rInt, rInt, rInt) + resourceName := "aws_kinesis_firehose_delivery_stream.test" resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -204,27 +212,27 @@ func TestAccAWSKinesisFirehoseDeliveryStream_s3basicWithTags(t *testing.T) { { Config: testAccKinesisFirehoseDeliveryStreamConfig_s3basicWithTags(rName, rInt), Check: resource.ComposeTestCheckFunc( - testAccCheckKinesisFirehoseDeliveryStreamExists("aws_kinesis_firehose_delivery_stream.test_stream", &stream), + testAccCheckKinesisFirehoseDeliveryStreamExists(resourceName, &stream), testAccCheckAWSKinesisFirehoseDeliveryStreamAttributes(&stream, nil, nil, nil, nil, nil), - resource.TestCheckResourceAttr("aws_kinesis_firehose_delivery_stream.test_stream", "tags.%", "2"), - resource.TestCheckResourceAttr("aws_kinesis_firehose_delivery_stream.test_stream", "tags.Usage", "original"), + resource.TestCheckResourceAttr(resourceName, "tags.%", "2"), + resource.TestCheckResourceAttr(resourceName, "tags.Usage", "original"), ), }, { Config: testAccKinesisFirehoseDeliveryStreamConfig_s3basicWithTagsChanged(rName, rInt), Check: resource.ComposeTestCheckFunc( - testAccCheckKinesisFirehoseDeliveryStreamExists("aws_kinesis_firehose_delivery_stream.test_stream", &stream), + testAccCheckKinesisFirehoseDeliveryStreamExists(resourceName, &stream), testAccCheckAWSKinesisFirehoseDeliveryStreamAttributes(&stream, nil, nil, nil, nil, nil), - resource.TestCheckResourceAttr("aws_kinesis_firehose_delivery_stream.test_stream", "tags.%", "1"), - resource.TestCheckResourceAttr("aws_kinesis_firehose_delivery_stream.test_stream", "tags.Usage", "changed"), + resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), + resource.TestCheckResourceAttr(resourceName, "tags.Usage", "changed"), ), }, { Config: config, Check: resource.ComposeTestCheckFunc( - testAccCheckKinesisFirehoseDeliveryStreamExists("aws_kinesis_firehose_delivery_stream.test_stream", &stream), + testAccCheckKinesisFirehoseDeliveryStreamExists(resourceName, &stream), testAccCheckAWSKinesisFirehoseDeliveryStreamAttributes(&stream, nil, nil, nil, nil, nil), - resource.TestCheckResourceAttr("aws_kinesis_firehose_delivery_stream.test_stream", "tags.%", "0"), + resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), ), }, }, @@ -234,6 +242,7 @@ func TestAccAWSKinesisFirehoseDeliveryStream_s3basicWithTags(t *testing.T) { func TestAccAWSKinesisFirehoseDeliveryStream_s3KinesisStreamSource(t *testing.T) { var stream firehose.DeliveryStreamDescription ri := acctest.RandInt() + resourceName := "aws_kinesis_firehose_delivery_stream.test" config := fmt.Sprintf(testAccKinesisFirehoseDeliveryStreamConfig_s3KinesisStreamSource, ri, ri, ri, ri, ri, ri, ri) @@ -245,7 +254,7 @@ func TestAccAWSKinesisFirehoseDeliveryStream_s3KinesisStreamSource(t *testing.T) { Config: config, Check: resource.ComposeTestCheckFunc( - testAccCheckKinesisFirehoseDeliveryStreamExists("aws_kinesis_firehose_delivery_stream.test_stream", &stream), + testAccCheckKinesisFirehoseDeliveryStreamExists(resourceName, &stream), testAccCheckAWSKinesisFirehoseDeliveryStreamAttributes(&stream, nil, nil, nil, nil, nil), ), }, @@ -256,6 +265,7 @@ func TestAccAWSKinesisFirehoseDeliveryStream_s3KinesisStreamSource(t *testing.T) func TestAccAWSKinesisFirehoseDeliveryStream_s3WithCloudwatchLogging(t *testing.T) { var stream firehose.DeliveryStreamDescription ri := acctest.RandInt() + resourceName := "aws_kinesis_firehose_delivery_stream.test" resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -265,7 +275,7 @@ func TestAccAWSKinesisFirehoseDeliveryStream_s3WithCloudwatchLogging(t *testing. { Config: testAccKinesisFirehoseDeliveryStreamConfig_s3WithCloudwatchLogging(ri), Check: resource.ComposeTestCheckFunc( - testAccCheckKinesisFirehoseDeliveryStreamExists("aws_kinesis_firehose_delivery_stream.test_stream", &stream), + testAccCheckKinesisFirehoseDeliveryStreamExists(resourceName, &stream), testAccCheckAWSKinesisFirehoseDeliveryStreamAttributes(&stream, nil, nil, nil, nil, nil), ), }, @@ -275,6 +285,7 @@ func TestAccAWSKinesisFirehoseDeliveryStream_s3WithCloudwatchLogging(t *testing. func TestAccAWSKinesisFirehoseDeliveryStream_s3ConfigUpdates(t *testing.T) { var stream firehose.DeliveryStreamDescription + resourceName := "aws_kinesis_firehose_delivery_stream.test" ri := acctest.RandInt() preConfig := fmt.Sprintf(testAccKinesisFirehoseDeliveryStreamConfig_s3basic, @@ -297,15 +308,14 @@ func TestAccAWSKinesisFirehoseDeliveryStream_s3ConfigUpdates(t *testing.T) { { Config: preConfig, Check: resource.ComposeTestCheckFunc( - testAccCheckKinesisFirehoseDeliveryStreamExists("aws_kinesis_firehose_delivery_stream.test_stream", &stream), + testAccCheckKinesisFirehoseDeliveryStreamExists(resourceName, &stream), testAccCheckAWSKinesisFirehoseDeliveryStreamAttributes(&stream, nil, nil, nil, nil, nil), ), }, - { Config: postConfig, Check: resource.ComposeTestCheckFunc( - testAccCheckKinesisFirehoseDeliveryStreamExists("aws_kinesis_firehose_delivery_stream.test_stream", &stream), + testAccCheckKinesisFirehoseDeliveryStreamExists(resourceName, &stream), testAccCheckAWSKinesisFirehoseDeliveryStreamAttributes(&stream, updatedS3DestinationConfig, nil, nil, nil, nil), ), }, @@ -318,6 +328,7 @@ func TestAccAWSKinesisFirehoseDeliveryStream_ExtendedS3basic(t *testing.T) { funcName := fmt.Sprintf("aws_kinesis_firehose_delivery_stream_test_%s", rString) policyName := fmt.Sprintf("tf_acc_policy_%s", rString) roleName := fmt.Sprintf("tf_acc_role_%s", rString) + resourceName := "aws_kinesis_firehose_delivery_stream.test" var stream firehose.DeliveryStreamDescription ri := acctest.RandInt() @@ -333,14 +344,14 @@ func TestAccAWSKinesisFirehoseDeliveryStream_ExtendedS3basic(t *testing.T) { { Config: config, Check: resource.ComposeTestCheckFunc( - testAccCheckKinesisFirehoseDeliveryStreamExists("aws_kinesis_firehose_delivery_stream.test_stream", &stream), + testAccCheckKinesisFirehoseDeliveryStreamExists(resourceName, &stream), testAccCheckAWSKinesisFirehoseDeliveryStreamAttributes(&stream, nil, nil, nil, nil, nil), - resource.TestCheckResourceAttr("aws_kinesis_firehose_delivery_stream.test_stream", "extended_s3_configuration.#", "1"), - resource.TestCheckResourceAttr("aws_kinesis_firehose_delivery_stream.test_stream", "extended_s3_configuration.0.error_output_prefix", ""), + resource.TestCheckResourceAttr(resourceName, "extended_s3_configuration.#", "1"), + resource.TestCheckResourceAttr(resourceName, "extended_s3_configuration.0.error_output_prefix", ""), ), }, { - ResourceName: "aws_kinesis_firehose_delivery_stream.test_stream", + ResourceName: resourceName, ImportState: true, ImportStateVerify: true, }, @@ -415,6 +426,11 @@ func TestAccAWSKinesisFirehoseDeliveryStream_ExtendedS3_ExternalUpdate(t *testin resource.TestCheckResourceAttr(resourceName, "extended_s3_configuration.0.processing_configuration.#", "1"), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, { PreConfig: func() { conn := testAccProvider.Meta().(*AWSClient).firehoseconn @@ -471,6 +487,11 @@ func TestAccAWSKinesisFirehoseDeliveryStream_ExtendedS3_DataFormatConversionConf resource.TestCheckResourceAttr(resourceName, "extended_s3_configuration.0.data_format_conversion_configuration.0.input_format_configuration.0.deserializer.0.hive_json_ser_de.#", "1"), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, { Config: testAccKinesisFirehoseDeliveryStreamConfig_ExtendedS3_DataFormatConversionConfiguration_OpenXJsonSerDe_Empty(rName, rInt), Check: resource.ComposeTestCheckFunc( @@ -632,6 +653,11 @@ func TestAccAWSKinesisFirehoseDeliveryStream_ExtendedS3_DataFormatConversionConf resource.TestCheckResourceAttr(resourceName, "extended_s3_configuration.0.data_format_conversion_configuration.0.output_format_configuration.0.serializer.0.orc_ser_de.#", "1"), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, { Config: testAccKinesisFirehoseDeliveryStreamConfig_ExtendedS3_DataFormatConversionConfiguration_ParquetSerDe_Empty(rName, rInt), Check: resource.ComposeTestCheckFunc( @@ -688,7 +714,7 @@ func TestAccAWSKinesisFirehoseDeliveryStream_ExtendedS3KmsKeyArn(t *testing.T) { funcName := fmt.Sprintf("aws_kinesis_firehose_delivery_stream_test_%s", rString) policyName := fmt.Sprintf("tf_acc_policy_%s", rString) roleName := fmt.Sprintf("tf_acc_role_%s", rString) - resourceName := "aws_kinesis_firehose_delivery_stream.test_stream" + resourceName := "aws_kinesis_firehose_delivery_stream.test" var stream firehose.DeliveryStreamDescription ri := acctest.RandInt() @@ -709,6 +735,11 @@ func TestAccAWSKinesisFirehoseDeliveryStream_ExtendedS3KmsKeyArn(t *testing.T) { resource.TestMatchResourceAttr(resourceName, "extended_s3_configuration.0.kms_key_arn", regexp.MustCompile(`^arn:[^:]+:kms:[^:]+:[^:]+:key/.+$`)), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, }, }) } @@ -718,6 +749,7 @@ func TestAccAWSKinesisFirehoseDeliveryStream_ExtendedS3Updates(t *testing.T) { funcName := fmt.Sprintf("aws_kinesis_firehose_delivery_stream_test_%s", rString) policyName := fmt.Sprintf("tf_acc_policy_%s", rString) roleName := fmt.Sprintf("tf_acc_role_%s", rString) + resourceName := "aws_kinesis_firehose_delivery_stream.test" var stream firehose.DeliveryStreamDescription ri := acctest.RandInt() @@ -759,14 +791,19 @@ func TestAccAWSKinesisFirehoseDeliveryStream_ExtendedS3Updates(t *testing.T) { { Config: preConfig, Check: resource.ComposeTestCheckFunc( - testAccCheckKinesisFirehoseDeliveryStreamExists("aws_kinesis_firehose_delivery_stream.test_stream", &stream), + testAccCheckKinesisFirehoseDeliveryStreamExists(resourceName, &stream), testAccCheckAWSKinesisFirehoseDeliveryStreamAttributes(&stream, nil, nil, nil, nil, nil), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, { Config: postConfig, Check: resource.ComposeTestCheckFunc( - testAccCheckKinesisFirehoseDeliveryStreamExists("aws_kinesis_firehose_delivery_stream.test_stream", &stream), + testAccCheckKinesisFirehoseDeliveryStreamExists(resourceName, &stream), testAccCheckAWSKinesisFirehoseDeliveryStreamAttributes(&stream, nil, updatedExtendedS3DestinationConfig, nil, nil, nil), ), }, @@ -777,6 +814,7 @@ func TestAccAWSKinesisFirehoseDeliveryStream_ExtendedS3Updates(t *testing.T) { func TestAccAWSKinesisFirehoseDeliveryStream_RedshiftConfigUpdates(t *testing.T) { var stream firehose.DeliveryStreamDescription + resourceName := "aws_kinesis_firehose_delivery_stream.test" ri := acctest.RandInt() rString := acctest.RandString(8) funcName := fmt.Sprintf("aws_kinesis_firehose_delivery_stream_test_%s", rString) @@ -817,15 +855,20 @@ func TestAccAWSKinesisFirehoseDeliveryStream_RedshiftConfigUpdates(t *testing.T) { Config: preConfig, Check: resource.ComposeTestCheckFunc( - testAccCheckKinesisFirehoseDeliveryStreamExists("aws_kinesis_firehose_delivery_stream.test_stream", &stream), + testAccCheckKinesisFirehoseDeliveryStreamExists(resourceName, &stream), testAccCheckAWSKinesisFirehoseDeliveryStreamAttributes(&stream, nil, nil, nil, nil, nil), ), }, - + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"redshift_configuration.0.password"}, + }, { Config: postConfig, Check: resource.ComposeTestCheckFunc( - testAccCheckKinesisFirehoseDeliveryStreamExists("aws_kinesis_firehose_delivery_stream.test_stream", &stream), + testAccCheckKinesisFirehoseDeliveryStreamExists(resourceName, &stream), testAccCheckAWSKinesisFirehoseDeliveryStreamAttributes(&stream, nil, nil, updatedRedshiftConfig, nil, nil), ), }, @@ -837,7 +880,7 @@ func TestAccAWSKinesisFirehoseDeliveryStream_SplunkConfigUpdates(t *testing.T) { var stream firehose.DeliveryStreamDescription ri := acctest.RandInt() - + resourceName := "aws_kinesis_firehose_delivery_stream.test" rString := acctest.RandString(8) funcName := fmt.Sprintf("aws_kinesis_firehose_delivery_stream_test_%s", rString) policyName := fmt.Sprintf("tf_acc_policy_%s", rString) @@ -877,15 +920,19 @@ func TestAccAWSKinesisFirehoseDeliveryStream_SplunkConfigUpdates(t *testing.T) { { Config: preConfig, Check: resource.ComposeTestCheckFunc( - testAccCheckKinesisFirehoseDeliveryStreamExists("aws_kinesis_firehose_delivery_stream.test_stream", &stream), + testAccCheckKinesisFirehoseDeliveryStreamExists(resourceName, &stream), testAccCheckAWSKinesisFirehoseDeliveryStreamAttributes(&stream, nil, nil, nil, nil, nil), ), }, - + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, { Config: postConfig, Check: resource.ComposeTestCheckFunc( - testAccCheckKinesisFirehoseDeliveryStreamExists("aws_kinesis_firehose_delivery_stream.test_stream", &stream), + testAccCheckKinesisFirehoseDeliveryStreamExists(resourceName, &stream), testAccCheckAWSKinesisFirehoseDeliveryStreamAttributes(&stream, nil, nil, nil, nil, updatedSplunkConfig), ), }, @@ -896,6 +943,7 @@ func TestAccAWSKinesisFirehoseDeliveryStream_SplunkConfigUpdates(t *testing.T) { func TestAccAWSKinesisFirehoseDeliveryStream_ElasticsearchConfigUpdates(t *testing.T) { var stream firehose.DeliveryStreamDescription + resourceName := "aws_kinesis_firehose_delivery_stream.test" ri := acctest.RandInt() rString := acctest.RandString(8) funcName := fmt.Sprintf("aws_kinesis_firehose_delivery_stream_test_%s", rString) @@ -935,14 +983,19 @@ func TestAccAWSKinesisFirehoseDeliveryStream_ElasticsearchConfigUpdates(t *testi { Config: preConfig, Check: resource.ComposeTestCheckFunc( - testAccCheckKinesisFirehoseDeliveryStreamExists("aws_kinesis_firehose_delivery_stream.test_stream_es", &stream), + testAccCheckKinesisFirehoseDeliveryStreamExists("aws_kinesis_firehose_delivery_stream.test", &stream), testAccCheckAWSKinesisFirehoseDeliveryStreamAttributes(&stream, nil, nil, nil, nil, nil), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, { Config: postConfig, Check: resource.ComposeTestCheckFunc( - testAccCheckKinesisFirehoseDeliveryStreamExists("aws_kinesis_firehose_delivery_stream.test_stream_es", &stream), + testAccCheckKinesisFirehoseDeliveryStreamExists("aws_kinesis_firehose_delivery_stream.test", &stream), testAccCheckAWSKinesisFirehoseDeliveryStreamAttributes(&stream, nil, nil, nil, updatedElasticSearchConfig, nil), ), }, @@ -954,6 +1007,7 @@ func TestAccAWSKinesisFirehoseDeliveryStream_ElasticsearchConfigUpdates(t *testi func TestAccAWSKinesisFirehoseDeliveryStream_missingProcessingConfiguration(t *testing.T) { var stream firehose.DeliveryStreamDescription ri := acctest.RandInt() + resourceName := "aws_kinesis_firehose_delivery_stream.test" resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -963,10 +1017,15 @@ func TestAccAWSKinesisFirehoseDeliveryStream_missingProcessingConfiguration(t *t { Config: testAccKinesisFirehoseDeliveryStreamConfig_missingProcessingConfiguration(ri), Check: resource.ComposeTestCheckFunc( - testAccCheckKinesisFirehoseDeliveryStreamExists("aws_kinesis_firehose_delivery_stream.test_stream", &stream), + testAccCheckKinesisFirehoseDeliveryStreamExists(resourceName, &stream), testAccCheckAWSKinesisFirehoseDeliveryStreamAttributes(&stream, nil, nil, nil, nil, nil), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, }, }) } @@ -1473,7 +1532,7 @@ resource "aws_cloudwatch_log_stream" "test" { log_group_name = "${aws_cloudwatch_log_group.test.name}" } -resource "aws_kinesis_firehose_delivery_stream" "test_stream" { +resource "aws_kinesis_firehose_delivery_stream" "test" { depends_on = ["aws_iam_role_policy.firehose"] name = "terraform-kinesis-firehose-cloudwatch-%d" destination = "s3" @@ -1493,7 +1552,7 @@ resource "aws_kinesis_firehose_delivery_stream" "test_stream" { } var testAccKinesisFirehoseDeliveryStreamConfig_s3basic = testAccKinesisFirehoseDeliveryStreamBaseConfig + ` -resource "aws_kinesis_firehose_delivery_stream" "test_stream" { +resource "aws_kinesis_firehose_delivery_stream" "test" { depends_on = ["aws_iam_role_policy.firehose"] name = "terraform-kinesis-firehose-basictest-%d" destination = "s3" @@ -1506,7 +1565,7 @@ resource "aws_kinesis_firehose_delivery_stream" "test_stream" { func testAccKinesisFirehoseDeliveryStreamConfig_s3basicWithSSE(rName string, rInt int, sseEnabled bool) string { return fmt.Sprintf(testAccKinesisFirehoseDeliveryStreamBaseConfig, rInt, rInt, rInt) + fmt.Sprintf(` -resource "aws_kinesis_firehose_delivery_stream" "test_stream" { +resource "aws_kinesis_firehose_delivery_stream" "test" { depends_on = ["aws_iam_role_policy.firehose"] name = "%s" destination = "s3" @@ -1525,7 +1584,7 @@ resource "aws_kinesis_firehose_delivery_stream" "test_stream" { func testAccKinesisFirehoseDeliveryStreamConfig_s3basicWithTags(rName string, rInt int) string { return fmt.Sprintf(testAccKinesisFirehoseDeliveryStreamBaseConfig, rInt, rInt, rInt) + fmt.Sprintf(` - resource "aws_kinesis_firehose_delivery_stream" "test_stream" { + resource "aws_kinesis_firehose_delivery_stream" "test" { depends_on = ["aws_iam_role_policy.firehose"] name = "%s" destination = "s3" @@ -1544,7 +1603,7 @@ func testAccKinesisFirehoseDeliveryStreamConfig_s3basicWithTags(rName string, rI func testAccKinesisFirehoseDeliveryStreamConfig_s3basicWithTagsChanged(rName string, rInt int) string { return fmt.Sprintf(testAccKinesisFirehoseDeliveryStreamBaseConfig, rInt, rInt, rInt) + fmt.Sprintf(` - resource "aws_kinesis_firehose_delivery_stream" "test_stream" { + resource "aws_kinesis_firehose_delivery_stream" "test" { depends_on = ["aws_iam_role_policy.firehose"] name = "%s" destination = "s3" @@ -1560,7 +1619,7 @@ func testAccKinesisFirehoseDeliveryStreamConfig_s3basicWithTagsChanged(rName str } var testAccKinesisFirehoseDeliveryStreamConfig_s3KinesisStreamSource = testAccKinesisFirehoseDeliveryStreamBaseConfig + testAccFirehoseKinesisStreamSource + ` -resource "aws_kinesis_firehose_delivery_stream" "test_stream" { +resource "aws_kinesis_firehose_delivery_stream" "test" { depends_on = ["aws_iam_role_policy.firehose", "aws_iam_role_policy.kinesis_source"] name = "terraform-kinesis-firehose-basictest-%d" kinesis_source_configuration { @@ -1575,7 +1634,7 @@ resource "aws_kinesis_firehose_delivery_stream" "test_stream" { }` var testAccKinesisFirehoseDeliveryStreamConfig_s3Updates = testAccKinesisFirehoseDeliveryStreamBaseConfig + ` -resource "aws_kinesis_firehose_delivery_stream" "test_stream" { +resource "aws_kinesis_firehose_delivery_stream" "test" { depends_on = ["aws_iam_role_policy.firehose"] name = "terraform-kinesis-firehose-s3test-%d" destination = "s3" @@ -1589,7 +1648,7 @@ resource "aws_kinesis_firehose_delivery_stream" "test_stream" { }` var testAccKinesisFirehoseDeliveryStreamConfig_extendedS3basic = testAccKinesisFirehoseDeliveryStreamBaseConfig + ` -resource "aws_kinesis_firehose_delivery_stream" "test_stream" { +resource "aws_kinesis_firehose_delivery_stream" "test" { depends_on = ["aws_iam_role_policy.firehose"] name = "terraform-kinesis-firehose-basictest-%d" destination = "extended_s3" @@ -1919,7 +1978,7 @@ resource "aws_kms_key" "test" { description = "Terraform acc test %s" } -resource "aws_kinesis_firehose_delivery_stream" "test_stream" { +resource "aws_kinesis_firehose_delivery_stream" "test" { depends_on = ["aws_iam_role_policy.firehose"] name = "terraform-kinesis-firehose-basictest-%d" destination = "extended_s3" @@ -1942,7 +2001,7 @@ resource "aws_kinesis_firehose_delivery_stream" "test_stream" { ` var testAccKinesisFirehoseDeliveryStreamConfig_extendedS3Updates = testAccKinesisFirehoseDeliveryStreamBaseConfig + ` -resource "aws_kinesis_firehose_delivery_stream" "test_stream" { +resource "aws_kinesis_firehose_delivery_stream" "test" { depends_on = ["aws_iam_role_policy.firehose"] name = "terraform-kinesis-firehose-basictest-%d" destination = "extended_s3" @@ -1983,7 +2042,7 @@ resource "aws_redshift_cluster" "test_cluster" { }` var testAccKinesisFirehoseDeliveryStreamConfig_RedshiftBasic = testAccKinesisFirehoseDeliveryStreamBaseRedshiftConfig + ` -resource "aws_kinesis_firehose_delivery_stream" "test_stream" { +resource "aws_kinesis_firehose_delivery_stream" "test" { depends_on = ["aws_iam_role_policy.firehose", "aws_redshift_cluster.test_cluster"] name = "terraform-kinesis-firehose-basicredshifttest-%d" destination = "redshift" @@ -2001,7 +2060,7 @@ resource "aws_kinesis_firehose_delivery_stream" "test_stream" { }` var testAccKinesisFirehoseDeliveryStreamConfig_RedshiftUpdates = testAccKinesisFirehoseDeliveryStreamBaseRedshiftConfig + ` -resource "aws_kinesis_firehose_delivery_stream" "test_stream" { +resource "aws_kinesis_firehose_delivery_stream" "test" { depends_on = ["aws_iam_role_policy.firehose", "aws_redshift_cluster.test_cluster"] name = "terraform-kinesis-firehose-basicredshifttest-%d" destination = "redshift" @@ -2039,7 +2098,7 @@ resource "aws_kinesis_firehose_delivery_stream" "test_stream" { }` var testAccKinesisFirehoseDeliveryStreamConfig_SplunkBasic = testAccKinesisFirehoseDeliveryStreamBaseConfig + ` -resource "aws_kinesis_firehose_delivery_stream" "test_stream" { +resource "aws_kinesis_firehose_delivery_stream" "test" { depends_on = ["aws_iam_role_policy.firehose"] name = "terraform-kinesis-firehose-basicsplunktest-%d" destination = "splunk" @@ -2054,7 +2113,7 @@ resource "aws_kinesis_firehose_delivery_stream" "test_stream" { }` var testAccKinesisFirehoseDeliveryStreamConfig_SplunkUpdates = testAccKinesisFirehoseDeliveryStreamBaseConfig + ` -resource "aws_kinesis_firehose_delivery_stream" "test_stream" { +resource "aws_kinesis_firehose_delivery_stream" "test" { depends_on = ["aws_iam_role_policy.firehose"] name = "terraform-kinesis-firehose-basicsplunktest-%d" destination = "splunk" @@ -2135,7 +2194,7 @@ EOF ` var testAccKinesisFirehoseDeliveryStreamConfig_ElasticsearchBasic = testAccKinesisFirehoseDeliveryStreamBaseElasticsearchConfig + ` -resource "aws_kinesis_firehose_delivery_stream" "test_stream_es" { +resource "aws_kinesis_firehose_delivery_stream" "test" { depends_on = ["aws_iam_role_policy.firehose-elasticsearch"] name = "terraform-kinesis-firehose-es-%d" @@ -2153,7 +2212,7 @@ resource "aws_kinesis_firehose_delivery_stream" "test_stream_es" { }` var testAccKinesisFirehoseDeliveryStreamConfig_ElasticsearchUpdate = testAccKinesisFirehoseDeliveryStreamBaseElasticsearchConfig + ` -resource "aws_kinesis_firehose_delivery_stream" "test_stream_es" { +resource "aws_kinesis_firehose_delivery_stream" "test" { depends_on = ["aws_iam_role_policy.firehose-elasticsearch"] name = "terraform-kinesis-firehose-es-%d" @@ -2248,7 +2307,7 @@ resource "aws_s3_bucket" "bucket" { acl = "private" } -resource "aws_kinesis_firehose_delivery_stream" "test_stream" { +resource "aws_kinesis_firehose_delivery_stream" "test" { name = "terraform-kinesis-firehose-mpc-%d" destination = "extended_s3" diff --git a/aws/resource_aws_kinesis_stream_test.go b/aws/resource_aws_kinesis_stream_test.go index d4ee961f670..88ef5dadd71 100644 --- a/aws/resource_aws_kinesis_stream_test.go +++ b/aws/resource_aws_kinesis_stream_test.go @@ -17,8 +17,9 @@ import ( func TestAccAWSKinesisStream_basic(t *testing.T) { var stream kinesis.StreamDescription - + resourceName := "aws_kinesis_stream.test" rInt := acctest.RandInt() + streamName := fmt.Sprintf("terraform-kinesis-test-%d", rInt) resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -28,18 +29,26 @@ func TestAccAWSKinesisStream_basic(t *testing.T) { { Config: testAccKinesisStreamConfig(rInt), Check: resource.ComposeTestCheckFunc( - testAccCheckKinesisStreamExists("aws_kinesis_stream.test_stream", &stream), + testAccCheckKinesisStreamExists(resourceName, &stream), testAccCheckAWSKinesisStreamAttributes(&stream), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateId: streamName, + ImportStateVerifyIgnore: []string{"enforce_consumer_deletion"}, + }, }, }) } func TestAccAWSKinesisStream_createMultipleConcurrentStreams(t *testing.T) { var stream kinesis.StreamDescription - + resourceName := "aws_kinesis_stream.test" rInt := acctest.RandInt() + streamName := fmt.Sprintf("terraform-kinesis-test-%d-0", rInt) // We can get away with just import testing one of them resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -49,28 +58,35 @@ func TestAccAWSKinesisStream_createMultipleConcurrentStreams(t *testing.T) { { Config: testAccKinesisStreamConfigConcurrent(rInt), Check: resource.ComposeTestCheckFunc( - testAccCheckKinesisStreamExists("aws_kinesis_stream.test_stream.0", &stream), - testAccCheckKinesisStreamExists("aws_kinesis_stream.test_stream.1", &stream), - testAccCheckKinesisStreamExists("aws_kinesis_stream.test_stream.2", &stream), - testAccCheckKinesisStreamExists("aws_kinesis_stream.test_stream.3", &stream), - testAccCheckKinesisStreamExists("aws_kinesis_stream.test_stream.4", &stream), - testAccCheckKinesisStreamExists("aws_kinesis_stream.test_stream.5", &stream), - testAccCheckKinesisStreamExists("aws_kinesis_stream.test_stream.6", &stream), - testAccCheckKinesisStreamExists("aws_kinesis_stream.test_stream.7", &stream), - testAccCheckKinesisStreamExists("aws_kinesis_stream.test_stream.8", &stream), - testAccCheckKinesisStreamExists("aws_kinesis_stream.test_stream.9", &stream), - testAccCheckKinesisStreamExists("aws_kinesis_stream.test_stream.10", &stream), - testAccCheckKinesisStreamExists("aws_kinesis_stream.test_stream.11", &stream), - testAccCheckKinesisStreamExists("aws_kinesis_stream.test_stream.12", &stream), - testAccCheckKinesisStreamExists("aws_kinesis_stream.test_stream.13", &stream), - testAccCheckKinesisStreamExists("aws_kinesis_stream.test_stream.14", &stream), - testAccCheckKinesisStreamExists("aws_kinesis_stream.test_stream.15", &stream), - testAccCheckKinesisStreamExists("aws_kinesis_stream.test_stream.16", &stream), - testAccCheckKinesisStreamExists("aws_kinesis_stream.test_stream.17", &stream), - testAccCheckKinesisStreamExists("aws_kinesis_stream.test_stream.18", &stream), - testAccCheckKinesisStreamExists("aws_kinesis_stream.test_stream.19", &stream), + testAccCheckKinesisStreamExists("aws_kinesis_stream.test.0", &stream), + testAccCheckKinesisStreamExists("aws_kinesis_stream.test.1", &stream), + testAccCheckKinesisStreamExists("aws_kinesis_stream.test.2", &stream), + testAccCheckKinesisStreamExists("aws_kinesis_stream.test.3", &stream), + testAccCheckKinesisStreamExists("aws_kinesis_stream.test.4", &stream), + testAccCheckKinesisStreamExists("aws_kinesis_stream.test.5", &stream), + testAccCheckKinesisStreamExists("aws_kinesis_stream.test.6", &stream), + testAccCheckKinesisStreamExists("aws_kinesis_stream.test.7", &stream), + testAccCheckKinesisStreamExists("aws_kinesis_stream.test.8", &stream), + testAccCheckKinesisStreamExists("aws_kinesis_stream.test.9", &stream), + testAccCheckKinesisStreamExists("aws_kinesis_stream.test.10", &stream), + testAccCheckKinesisStreamExists("aws_kinesis_stream.test.11", &stream), + testAccCheckKinesisStreamExists("aws_kinesis_stream.test.12", &stream), + testAccCheckKinesisStreamExists("aws_kinesis_stream.test.13", &stream), + testAccCheckKinesisStreamExists("aws_kinesis_stream.test.14", &stream), + testAccCheckKinesisStreamExists("aws_kinesis_stream.test.15", &stream), + testAccCheckKinesisStreamExists("aws_kinesis_stream.test.16", &stream), + testAccCheckKinesisStreamExists("aws_kinesis_stream.test.17", &stream), + testAccCheckKinesisStreamExists("aws_kinesis_stream.test.18", &stream), + testAccCheckKinesisStreamExists("aws_kinesis_stream.test.19", &stream), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateId: streamName, + ImportStateVerifyIgnore: []string{"enforce_consumer_deletion"}, + }, }, }) } @@ -94,6 +110,8 @@ func TestAccAWSKinesisStream_encryptionWithoutKmsKeyThrowsError(t *testing.T) { func TestAccAWSKinesisStream_encryption(t *testing.T) { var stream kinesis.StreamDescription rInt := acctest.RandInt() + resourceName := "aws_kinesis_stream.test" + streamName := fmt.Sprintf("terraform-kinesis-test-%d", rInt) resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -103,56 +121,38 @@ func TestAccAWSKinesisStream_encryption(t *testing.T) { { Config: testAccKinesisStreamConfigWithEncryption(rInt), Check: resource.ComposeTestCheckFunc( - testAccCheckKinesisStreamExists("aws_kinesis_stream.test_stream", &stream), + testAccCheckKinesisStreamExists(resourceName, &stream), resource.TestCheckResourceAttr( - "aws_kinesis_stream.test_stream", "encryption_type", "KMS"), + resourceName, "encryption_type", "KMS"), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateId: streamName, + ImportStateVerifyIgnore: []string{"enforce_consumer_deletion"}, + }, { Config: testAccKinesisStreamConfig(rInt), Check: resource.ComposeTestCheckFunc( - testAccCheckKinesisStreamExists("aws_kinesis_stream.test_stream", &stream), + testAccCheckKinesisStreamExists(resourceName, &stream), resource.TestCheckResourceAttr( - "aws_kinesis_stream.test_stream", "encryption_type", "NONE"), + resourceName, "encryption_type", "NONE"), ), }, { Config: testAccKinesisStreamConfigWithEncryption(rInt), Check: resource.ComposeTestCheckFunc( - testAccCheckKinesisStreamExists("aws_kinesis_stream.test_stream", &stream), + testAccCheckKinesisStreamExists(resourceName, &stream), resource.TestCheckResourceAttr( - "aws_kinesis_stream.test_stream", "encryption_type", "KMS"), + resourceName, "encryption_type", "KMS"), ), }, }, }) } -func TestAccAWSKinesisStream_importBasic(t *testing.T) { - rInt := acctest.RandInt() - resourceName := "aws_kinesis_stream.test_stream" - streamName := fmt.Sprintf("terraform-kinesis-test-%d", rInt) - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckKinesisStreamDestroy, - Steps: []resource.TestStep{ - { - Config: testAccKinesisStreamConfig(rInt), - }, - - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - ImportStateId: streamName, - ImportStateVerifyIgnore: []string{"enforce_consumer_deletion"}, - }, - }, - }) -} - func TestAccAWSKinesisStream_shardCount(t *testing.T) { var stream kinesis.StreamDescription var updatedStream kinesis.StreamDescription @@ -167,6 +167,8 @@ func TestAccAWSKinesisStream_shardCount(t *testing.T) { } rInt := acctest.RandInt() + resourceName := "aws_kinesis_stream.test" + streamName := fmt.Sprintf("terraform-kinesis-test-%d", rInt) resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -176,21 +178,27 @@ func TestAccAWSKinesisStream_shardCount(t *testing.T) { { Config: testAccKinesisStreamConfig(rInt), Check: resource.ComposeTestCheckFunc( - testAccCheckKinesisStreamExists("aws_kinesis_stream.test_stream", &stream), + testAccCheckKinesisStreamExists(resourceName, &stream), testAccCheckAWSKinesisStreamAttributes(&stream), resource.TestCheckResourceAttr( - "aws_kinesis_stream.test_stream", "shard_count", "2"), + resourceName, "shard_count", "2"), ), }, - + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateId: streamName, + ImportStateVerifyIgnore: []string{"enforce_consumer_deletion"}, + }, { Config: testAccKinesisStreamConfigUpdateShardCount(rInt), Check: resource.ComposeTestCheckFunc( - testAccCheckKinesisStreamExists("aws_kinesis_stream.test_stream", &updatedStream), + testAccCheckKinesisStreamExists(resourceName, &updatedStream), testAccCheckAWSKinesisStreamAttributes(&updatedStream), testCheckStreamNotDestroyed(), resource.TestCheckResourceAttr( - "aws_kinesis_stream.test_stream", "shard_count", "4"), + resourceName, "shard_count", "4"), ), }, }, @@ -199,8 +207,9 @@ func TestAccAWSKinesisStream_shardCount(t *testing.T) { func TestAccAWSKinesisStream_retentionPeriod(t *testing.T) { var stream kinesis.StreamDescription - + resourceName := "aws_kinesis_stream.test" rInt := acctest.RandInt() + streamName := fmt.Sprintf("terraform-kinesis-test-%d", rInt) resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -210,30 +219,36 @@ func TestAccAWSKinesisStream_retentionPeriod(t *testing.T) { { Config: testAccKinesisStreamConfig(rInt), Check: resource.ComposeTestCheckFunc( - testAccCheckKinesisStreamExists("aws_kinesis_stream.test_stream", &stream), + testAccCheckKinesisStreamExists(resourceName, &stream), testAccCheckAWSKinesisStreamAttributes(&stream), resource.TestCheckResourceAttr( - "aws_kinesis_stream.test_stream", "retention_period", "24"), + resourceName, "retention_period", "24"), ), }, - + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateId: streamName, + ImportStateVerifyIgnore: []string{"enforce_consumer_deletion"}, + }, { Config: testAccKinesisStreamConfigUpdateRetentionPeriod(rInt), Check: resource.ComposeTestCheckFunc( - testAccCheckKinesisStreamExists("aws_kinesis_stream.test_stream", &stream), + testAccCheckKinesisStreamExists(resourceName, &stream), testAccCheckAWSKinesisStreamAttributes(&stream), resource.TestCheckResourceAttr( - "aws_kinesis_stream.test_stream", "retention_period", "100"), + resourceName, "retention_period", "100"), ), }, { Config: testAccKinesisStreamConfigDecreaseRetentionPeriod(rInt), Check: resource.ComposeTestCheckFunc( - testAccCheckKinesisStreamExists("aws_kinesis_stream.test_stream", &stream), + testAccCheckKinesisStreamExists(resourceName, &stream), testAccCheckAWSKinesisStreamAttributes(&stream), resource.TestCheckResourceAttr( - "aws_kinesis_stream.test_stream", "retention_period", "28"), + resourceName, "retention_period", "28"), ), }, }, @@ -242,8 +257,9 @@ func TestAccAWSKinesisStream_retentionPeriod(t *testing.T) { func TestAccAWSKinesisStream_shardLevelMetrics(t *testing.T) { var stream kinesis.StreamDescription - + resourceName := "aws_kinesis_stream.test" rInt := acctest.RandInt() + streamName := fmt.Sprintf("terraform-kinesis-test-%d", rInt) resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -253,30 +269,36 @@ func TestAccAWSKinesisStream_shardLevelMetrics(t *testing.T) { { Config: testAccKinesisStreamConfig(rInt), Check: resource.ComposeTestCheckFunc( - testAccCheckKinesisStreamExists("aws_kinesis_stream.test_stream", &stream), + testAccCheckKinesisStreamExists(resourceName, &stream), testAccCheckAWSKinesisStreamAttributes(&stream), resource.TestCheckNoResourceAttr( - "aws_kinesis_stream.test_stream", "shard_level_metrics"), + resourceName, "shard_level_metrics"), ), }, - + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateId: streamName, + ImportStateVerifyIgnore: []string{"enforce_consumer_deletion"}, + }, { Config: testAccKinesisStreamConfigAllShardLevelMetrics(rInt), Check: resource.ComposeTestCheckFunc( - testAccCheckKinesisStreamExists("aws_kinesis_stream.test_stream", &stream), + testAccCheckKinesisStreamExists(resourceName, &stream), testAccCheckAWSKinesisStreamAttributes(&stream), resource.TestCheckResourceAttr( - "aws_kinesis_stream.test_stream", "shard_level_metrics.#", "7"), + resourceName, "shard_level_metrics.#", "7"), ), }, { Config: testAccKinesisStreamConfigSingleShardLevelMetric(rInt), Check: resource.ComposeTestCheckFunc( - testAccCheckKinesisStreamExists("aws_kinesis_stream.test_stream", &stream), + testAccCheckKinesisStreamExists(resourceName, &stream), testAccCheckAWSKinesisStreamAttributes(&stream), resource.TestCheckResourceAttr( - "aws_kinesis_stream.test_stream", "shard_level_metrics.#", "1"), + resourceName, "shard_level_metrics.#", "1"), ), }, }, @@ -285,8 +307,9 @@ func TestAccAWSKinesisStream_shardLevelMetrics(t *testing.T) { func TestAccAWSKinesisStream_enforceConsumerDeletion(t *testing.T) { var stream kinesis.StreamDescription - + resourceName := "aws_kinesis_stream.test" rInt := acctest.RandInt() + streamName := fmt.Sprintf("terraform-kinesis-test-%d", rInt) resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -296,11 +319,18 @@ func TestAccAWSKinesisStream_enforceConsumerDeletion(t *testing.T) { { Config: testAccKinesisStreamConfigWithEnforceConsumerDeletion(rInt), Check: resource.ComposeTestCheckFunc( - testAccCheckKinesisStreamExists("aws_kinesis_stream.test_stream", &stream), + testAccCheckKinesisStreamExists(resourceName, &stream), testAccCheckAWSKinesisStreamAttributes(&stream), testAccAWSKinesisStreamRegisterStreamConsumer(&stream, fmt.Sprintf("tf-test-%d", rInt)), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateId: streamName, + ImportStateVerifyIgnore: []string{"enforce_consumer_deletion"}, + }, }, }) } @@ -308,8 +338,8 @@ func TestAccAWSKinesisStream_enforceConsumerDeletion(t *testing.T) { func TestAccAWSKinesisStream_Tags(t *testing.T) { var stream kinesis.StreamDescription resourceName := "aws_kinesis_stream.test" - rInt := acctest.RandInt() + streamName := fmt.Sprintf("terraform-kinesis-test-%d", rInt) resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -323,6 +353,13 @@ func TestAccAWSKinesisStream_Tags(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "tags.%", "21"), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateId: streamName, + ImportStateVerifyIgnore: []string{"enforce_consumer_deletion"}, + }, { Config: testAccKinesisStreamConfig_Tags(rInt, 9), Check: resource.ComposeTestCheckFunc( @@ -421,7 +458,7 @@ func testAccAWSKinesisStreamRegisterStreamConsumer(stream *kinesis.StreamDescrip func testAccKinesisStreamConfig(rInt int) string { return fmt.Sprintf(` -resource "aws_kinesis_stream" "test_stream" { +resource "aws_kinesis_stream" "test" { name = "terraform-kinesis-test-%d" shard_count = 2 @@ -434,7 +471,7 @@ resource "aws_kinesis_stream" "test_stream" { func testAccKinesisStreamConfigConcurrent(rInt int) string { return fmt.Sprintf(` -resource "aws_kinesis_stream" "test_stream" { +resource "aws_kinesis_stream" "test" { count = 20 name = "terraform-kinesis-test-%d-${count.index}" shard_count = 2 @@ -448,7 +485,7 @@ resource "aws_kinesis_stream" "test_stream" { func testAccKinesisStreamConfigWithEncryptionAndNoKmsKey(rInt int) string { return fmt.Sprintf(` -resource "aws_kinesis_stream" "test_stream" { +resource "aws_kinesis_stream" "test" { name = "terraform-kinesis-test-%d" shard_count = 2 encryption_type = "KMS" @@ -462,7 +499,7 @@ resource "aws_kinesis_stream" "test_stream" { func testAccKinesisStreamConfigWithEncryption(rInt int) string { return fmt.Sprintf(` -resource "aws_kinesis_stream" "test_stream" { +resource "aws_kinesis_stream" "test" { name = "terraform-kinesis-test-%d" shard_count = 2 encryption_type = "KMS" @@ -500,7 +537,7 @@ POLICY func testAccKinesisStreamConfigUpdateShardCount(rInt int) string { return fmt.Sprintf(` -resource "aws_kinesis_stream" "test_stream" { +resource "aws_kinesis_stream" "test" { name = "terraform-kinesis-test-%d" shard_count = 4 @@ -513,7 +550,7 @@ resource "aws_kinesis_stream" "test_stream" { func testAccKinesisStreamConfigUpdateRetentionPeriod(rInt int) string { return fmt.Sprintf(` -resource "aws_kinesis_stream" "test_stream" { +resource "aws_kinesis_stream" "test" { name = "terraform-kinesis-test-%d" shard_count = 2 retention_period = 100 @@ -527,7 +564,7 @@ resource "aws_kinesis_stream" "test_stream" { func testAccKinesisStreamConfigDecreaseRetentionPeriod(rInt int) string { return fmt.Sprintf(` -resource "aws_kinesis_stream" "test_stream" { +resource "aws_kinesis_stream" "test" { name = "terraform-kinesis-test-%d" shard_count = 2 retention_period = 28 @@ -541,7 +578,7 @@ resource "aws_kinesis_stream" "test_stream" { func testAccKinesisStreamConfigAllShardLevelMetrics(rInt int) string { return fmt.Sprintf(` -resource "aws_kinesis_stream" "test_stream" { +resource "aws_kinesis_stream" "test" { name = "terraform-kinesis-test-%d" shard_count = 2 @@ -564,7 +601,7 @@ resource "aws_kinesis_stream" "test_stream" { func testAccKinesisStreamConfigSingleShardLevelMetric(rInt int) string { return fmt.Sprintf(` -resource "aws_kinesis_stream" "test_stream" { +resource "aws_kinesis_stream" "test" { name = "terraform-kinesis-test-%d" shard_count = 2 @@ -599,7 +636,7 @@ resource "aws_kinesis_stream" "test" { func testAccKinesisStreamConfigWithEnforceConsumerDeletion(rInt int) string { return fmt.Sprintf(` -resource "aws_kinesis_stream" "test_stream" { +resource "aws_kinesis_stream" "test" { name = "terraform-kinesis-test-%d" shard_count = 2 enforce_consumer_deletion = true