mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-08 15:13:56 -06:00
8159731c91
Allows users from govcloud and other regions (aws-cn) to now use the following resources correctly: ``` - data "aws_billing_service_account" - data "aws_elb_service_account" - resource "aws_cloudfront_origin_access_identity" - resource "aws_ecs_service" - resource "aws_iam_saml_provider" - resource "aws_lambda_permission" - resource "aws_sns_topic_policy" ```
50 lines
1.2 KiB
Go
50 lines
1.2 KiB
Go
package aws
|
|
|
|
import (
|
|
"regexp"
|
|
"testing"
|
|
|
|
"github.com/hashicorp/terraform/helper/resource"
|
|
)
|
|
|
|
func TestAccAWSSNSTopicPolicy_basic(t *testing.T) {
|
|
resource.Test(t, resource.TestCase{
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
Providers: testAccProviders,
|
|
CheckDestroy: testAccCheckAWSSNSTopicDestroy,
|
|
Steps: []resource.TestStep{
|
|
{
|
|
Config: testAccAWSSNSTopicConfig_withPolicy,
|
|
Check: resource.ComposeTestCheckFunc(
|
|
testAccCheckAWSSNSTopicExists("aws_sns_topic.test"),
|
|
resource.TestMatchResourceAttr("aws_sns_topic_policy.custom", "policy",
|
|
regexp.MustCompile("^{\"Version\":\"2012-10-17\".+")),
|
|
),
|
|
},
|
|
},
|
|
})
|
|
}
|
|
|
|
const testAccAWSSNSTopicConfig_withPolicy = `
|
|
resource "aws_sns_topic" "test" {
|
|
name = "tf-acc-test-topic-with-policy"
|
|
}
|
|
|
|
resource "aws_sns_topic_policy" "custom" {
|
|
arn = "${aws_sns_topic.test.arn}"
|
|
policy = <<POLICY
|
|
{
|
|
"Version":"2012-10-17",
|
|
"Id": "default",
|
|
"Statement":[{
|
|
"Sid":"default",
|
|
"Effect":"Allow",
|
|
"Principal":{"AWS":"*"},
|
|
"Action":["SNS:GetTopicAttributes","SNS:SetTopicAttributes","SNS:AddPermission","SNS:RemovePermission","SNS:DeleteTopic"],
|
|
"Resource":"${aws_sns_topic.test.arn}"
|
|
}]
|
|
}
|
|
POLICY
|
|
}
|
|
`
|