diff --git a/builtin/providers/aws/resource_aws_sns_topic_subscription_test.go b/builtin/providers/aws/resource_aws_sns_topic_subscription_test.go index 146d2fa92..3f730c9f7 100644 --- a/builtin/providers/aws/resource_aws_sns_topic_subscription_test.go +++ b/builtin/providers/aws/resource_aws_sns_topic_subscription_test.go @@ -31,6 +31,25 @@ func TestAccAWSSNSTopicSubscription_basic(t *testing.T) { }) } +func TestAccAWSSNSTopicSubscription_autoConfirmingEndpoint(t *testing.T) { + ri := acctest.RandInt() + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSNSTopicSubscriptionDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccAWSSNSTopicSubscriptionConfig_autoConfirmingEndpoint(ri), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSNSTopicExists("aws_sns_topic.test_topic"), + testAccCheckAWSSNSTopicSubscriptionExists("aws_sns_topic_subscription.test_subscription"), + ), + }, + }, + }) +} + func testAccCheckAWSSNSTopicSubscriptionDestroy(s *terraform.State) error { conn := testAccProvider.Meta().(*AWSClient).snsconn @@ -103,3 +122,126 @@ resource "aws_sns_topic_subscription" "test_subscription" { } `, i) } + +func testAccAWSSNSTopicSubscriptionConfig_autoConfirmingEndpoint(i int) string { + return fmt.Sprintf(` +resource "aws_sns_topic" "test_topic" { + name = "tf-acc-test-sns-%d" +} + +resource "aws_api_gateway_rest_api" "test" { + name = "tf-acc-test-sns-%d" + description = "Terraform Acceptance test for SNS subscription" +} + +resource "aws_api_gateway_method" "test" { + rest_api_id = "${aws_api_gateway_rest_api.test.id}" + resource_id = "${aws_api_gateway_rest_api.test.root_resource_id}" + http_method = "POST" + authorization = "NONE" +} + +resource "aws_api_gateway_method_response" "test" { + rest_api_id = "${aws_api_gateway_rest_api.test.id}" + resource_id = "${aws_api_gateway_rest_api.test.root_resource_id}" + http_method = "${aws_api_gateway_method.test.http_method}" + status_code = "200" + + response_parameters { + "method.response.header.Access-Control-Allow-Origin" = true + } +} + +resource "aws_api_gateway_integration" "test" { + rest_api_id = "${aws_api_gateway_rest_api.test.id}" + resource_id = "${aws_api_gateway_rest_api.test.root_resource_id}" + http_method = "${aws_api_gateway_method.test.http_method}" + integration_http_method = "POST" + type = "AWS" + uri = "${aws_lambda_function.lambda.invoke_arn}" +} + +resource "aws_api_gateway_integration_response" "test" { + depends_on = ["aws_api_gateway_integration.test"] + rest_api_id = "${aws_api_gateway_rest_api.test.id}" + resource_id = "${aws_api_gateway_rest_api.test.root_resource_id}" + http_method = "${aws_api_gateway_method.test.http_method}" + status_code = "${aws_api_gateway_method_response.test.status_code}" + + response_parameters { + "method.response.header.Access-Control-Allow-Origin" = "'*'" + } +} + +resource "aws_iam_role" "iam_for_lambda" { + name = "tf-acc-test-sns-%d" + + assume_role_policy = <