-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Add policy attribute to aws_api_gateway_rest_api #4211
Changes from 9 commits
035b4da
f7c81c1
59575bf
aeffaa4
ad8fd85
f055976
2e9f9ef
6be5d96
df094cb
c953fde
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,6 +127,24 @@ func TestAccAWSAPIGatewayRestApi_basic(t *testing.T) { | |
}) | ||
} | ||
|
||
func TestAccAWSAPIGatewayRestApi_policy(t *testing.T) { | ||
expectedPolicyText := fmt.Sprintf(`{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Principal":{"AWS":"*"},"Action":"execute-api:Invoke","Resource":"*"}]}`) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this work without the wrapping |
||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckAWSAPIGatewayRestAPIDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccAWSAPIGatewayRestAPIConfigWithPolicy, | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr("aws_api_gateway_rest_api.test", "policy", expectedPolicyText), | ||
), | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should add test steps that attempt to:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test steps for update and removal have been added |
||
}, | ||
}) | ||
} | ||
|
||
func TestAccAWSAPIGatewayRestApi_openapi(t *testing.T) { | ||
var conf apigateway.RestApi | ||
|
||
|
@@ -298,6 +316,28 @@ resource "aws_api_gateway_rest_api" "test" { | |
} | ||
` | ||
|
||
const testAccAWSAPIGatewayRestAPIConfigWithPolicy = ` | ||
resource "aws_api_gateway_rest_api" "test" { | ||
name = "bar" | ||
minimum_compression_size = 0 | ||
policy = <<EOF | ||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Effect": "Allow", | ||
"Principal": { | ||
"AWS": "*" | ||
}, | ||
"Action": "execute-api:Invoke", | ||
"Resource": "*" | ||
} | ||
] | ||
} | ||
EOF | ||
} | ||
` | ||
|
||
const testAccAWSAPIGatewayRestAPIUpdateConfig = ` | ||
resource "aws_api_gateway_rest_api" "test" { | ||
name = "test" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be simplified with (after
params
declaration):