-
Notifications
You must be signed in to change notification settings - Fork 2.5k
feat: Support EndpointAccessMode property for AWS::Serverless::Api #3898
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
integration/resources/expected/single/api_with_custom_domain_security_policy_edge.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| [ | ||
| { | ||
| "LogicalResourceId": "MyApi", | ||
| "ResourceType": "AWS::ApiGateway::RestApi" | ||
| }, | ||
| { | ||
| "LogicalResourceId": "MyApiDeployment", | ||
| "ResourceType": "AWS::ApiGateway::Deployment" | ||
| }, | ||
| { | ||
| "LogicalResourceId": "MyApiProdStage", | ||
| "ResourceType": "AWS::ApiGateway::Stage" | ||
| }, | ||
| { | ||
| "LogicalResourceId": "ApiGatewayDomainName", | ||
| "ResourceType": "AWS::ApiGateway::DomainName" | ||
| }, | ||
| { | ||
| "LogicalResourceId": "MyApiBasePathMapping", | ||
| "ResourceType": "AWS::ApiGateway::BasePathMapping" | ||
| }, | ||
| { | ||
| "LogicalResourceId": "RecordSetGroup", | ||
| "ResourceType": "AWS::Route53::RecordSetGroup" | ||
| } | ||
| ] |
26 changes: 26 additions & 0 deletions
26
integration/resources/expected/single/api_with_custom_domain_security_policy_regional.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| [ | ||
| { | ||
| "LogicalResourceId": "MyApi", | ||
| "ResourceType": "AWS::ApiGateway::RestApi" | ||
| }, | ||
| { | ||
| "LogicalResourceId": "MyApiDeployment", | ||
| "ResourceType": "AWS::ApiGateway::Deployment" | ||
| }, | ||
| { | ||
| "LogicalResourceId": "MyApiProdStage", | ||
| "ResourceType": "AWS::ApiGateway::Stage" | ||
| }, | ||
| { | ||
| "LogicalResourceId": "ApiGatewayDomainName", | ||
| "ResourceType": "AWS::ApiGateway::DomainName" | ||
| }, | ||
| { | ||
| "LogicalResourceId": "MyApiBasePathMapping", | ||
| "ResourceType": "AWS::ApiGateway::BasePathMapping" | ||
| }, | ||
| { | ||
| "LogicalResourceId": "RecordSetGroup", | ||
| "ResourceType": "AWS::Route53::RecordSetGroup" | ||
| } | ||
| ] |
14 changes: 14 additions & 0 deletions
14
integration/resources/expected/single/api_with_endpoint_access_mode.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| [ | ||
| { | ||
| "LogicalResourceId": "MyApi", | ||
| "ResourceType": "AWS::ApiGateway::RestApi" | ||
| }, | ||
| { | ||
| "LogicalResourceId": "MyApiDeployment", | ||
| "ResourceType": "AWS::ApiGateway::Deployment" | ||
| }, | ||
| { | ||
| "LogicalResourceId": "MyApiProdStage", | ||
| "ResourceType": "AWS::ApiGateway::Stage" | ||
| } | ||
| ] |
27 changes: 27 additions & 0 deletions
27
integration/resources/templates/single/api_with_custom_domain_security_policy_edge.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| Parameters: | ||
| DomainName: | ||
| Type: String | ||
| CertificateArn: | ||
| Type: String | ||
| HostedZoneId: | ||
| Type: String | ||
|
|
||
| Resources: | ||
| MyApi: | ||
| Type: AWS::Serverless::Api | ||
| Properties: | ||
| StageName: Prod | ||
| DefinitionUri: ${definitionuri} | ||
| EndpointConfiguration: | ||
| Type: EDGE | ||
| Domain: | ||
| DomainName: !Ref DomainName | ||
| CertificateArn: !Ref CertificateArn | ||
| EndpointConfiguration: EDGE | ||
| SecurityPolicy: SecurityPolicy_TLS13_2025_EDGE | ||
| EndpointAccessMode: STRICT | ||
| Route53: | ||
| HostedZoneId: !Ref HostedZoneId | ||
|
|
||
| Metadata: | ||
| SamTransformTest: true |
27 changes: 27 additions & 0 deletions
27
integration/resources/templates/single/api_with_custom_domain_security_policy_regional.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| Parameters: | ||
| DomainName: | ||
| Type: String | ||
| CertificateArn: | ||
| Type: String | ||
| HostedZoneId: | ||
| Type: String | ||
|
|
||
| Resources: | ||
| MyApi: | ||
| Type: AWS::Serverless::Api | ||
| Properties: | ||
| StageName: Prod | ||
| DefinitionUri: ${definitionuri} | ||
| EndpointConfiguration: | ||
| Type: REGIONAL | ||
| Domain: | ||
| DomainName: !Ref DomainName | ||
| CertificateArn: !Ref CertificateArn | ||
| EndpointConfiguration: REGIONAL | ||
| SecurityPolicy: SecurityPolicy_TLS13_1_3_2025_09 | ||
| EndpointAccessMode: STRICT | ||
| Route53: | ||
| HostedZoneId: !Ref HostedZoneId | ||
|
|
||
| Metadata: | ||
| SamTransformTest: true |
20 changes: 20 additions & 0 deletions
20
integration/resources/templates/single/api_with_endpoint_access_mode.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| Parameters: | ||
| SecurityPolicyValue: | ||
| Type: String | ||
| Default: SecurityPolicy_TLS13_1_3_2025_09 | ||
| EndpointAccessModeValue: | ||
| Type: String | ||
| Default: STRICT | ||
|
|
||
| Resources: | ||
| MyApi: | ||
| Type: AWS::Serverless::Api | ||
| Properties: | ||
| StageName: Prod | ||
| DefinitionUri: ${definitionuri} | ||
| SecurityPolicy: !Ref SecurityPolicyValue | ||
| EndpointAccessMode: !Ref EndpointAccessModeValue | ||
| EndpointConfiguration: | ||
| Type: REGIONAL | ||
| Metadata: | ||
| SamTransformTest: true |
39 changes: 39 additions & 0 deletions
39
integration/single/test_api_with_custom_domain_security_policy.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| from unittest.case import skipIf | ||
|
|
||
| from integration.config.service_names import CUSTOM_DOMAIN | ||
| from integration.helpers.base_internal_test import BaseInternalTest | ||
| from integration.helpers.base_test import nonblocking | ||
| from integration.helpers.resource import current_region_not_included | ||
|
|
||
|
|
||
| @skipIf( | ||
| current_region_not_included([CUSTOM_DOMAIN]), | ||
| "Custom domain is not supported in this testing region", | ||
| ) | ||
| @nonblocking | ||
| class TestApiWithCustomDomainSecurityPolicy(BaseInternalTest): | ||
| """ | ||
| Test AWS::Serverless::Api with SecurityPolicy and EndpointAccessMode in Domain configuration | ||
| """ | ||
|
|
||
| def test_api_with_custom_domain_security_policy_regional(self): | ||
| self.create_and_verify_stack("single/api_with_custom_domain_security_policy_regional") | ||
|
|
||
| domain_name_id = self.get_physical_id_by_type("AWS::ApiGateway::DomainName") | ||
| result = self.client_provider.api_client.get_domain_name(domainName=domain_name_id) | ||
|
|
||
| end_point_config = result["endpointConfiguration"] | ||
| self.assertEqual(["REGIONAL"], end_point_config["types"]) | ||
| self.assertEqual("SecurityPolicy_TLS13_1_3_2025_09", result["securityPolicy"]) | ||
| self.assertEqual("STRICT", result["endpointAccessMode"]) | ||
|
|
||
| def test_api_with_custom_domain_security_policy_edge(self): | ||
| self.create_and_verify_stack("single/api_with_custom_domain_security_policy_edge") | ||
|
|
||
| domain_name_id = self.get_physical_id_by_type("AWS::ApiGateway::DomainName") | ||
| result = self.client_provider.api_client.get_domain_name(domainName=domain_name_id) | ||
|
|
||
| end_point_config = result["endpointConfiguration"] | ||
| self.assertEqual(["EDGE"], end_point_config["types"]) | ||
| self.assertEqual("SecurityPolicy_TLS13_2025_EDGE", result["securityPolicy"]) | ||
| self.assertEqual("STRICT", result["endpointAccessMode"]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| from unittest.case import skipIf | ||
|
|
||
| from integration.config.service_names import REST_API | ||
| from integration.helpers.base_test import BaseTest | ||
| from integration.helpers.resource import current_region_does_not_support | ||
|
|
||
|
|
||
| @skipIf(current_region_does_not_support([REST_API]), "Rest API is not supported in this testing region") | ||
| class TestApiWithEndpointAccessMode(BaseTest): | ||
| """ | ||
| Tests for AWS::Serverless::Api with EndpointAccessMode property | ||
| """ | ||
|
|
||
| def test_api_with_endpoint_access_mode(self): | ||
| # Create stack with STRICT | ||
| parameters = [ | ||
| {"ParameterKey": "SecurityPolicyValue", "ParameterValue": "SecurityPolicy_TLS13_1_3_2025_09"}, | ||
| {"ParameterKey": "EndpointAccessModeValue", "ParameterValue": "STRICT"}, | ||
| ] | ||
| self.create_and_verify_stack("single/api_with_endpoint_access_mode", parameters) | ||
|
|
||
| rest_api_id = self.get_physical_id_by_type("AWS::ApiGateway::RestApi") | ||
| rest_api = self.client_provider.api_client.get_rest_api(restApiId=rest_api_id) | ||
|
|
||
| self.assertEqual(rest_api["securityPolicy"], "SecurityPolicy_TLS13_1_3_2025_09") | ||
| self.assertEqual(rest_api["endpointAccessMode"], "STRICT") | ||
|
|
||
| # Update stack with BASIC | ||
| update_parameters = [ | ||
| {"ParameterKey": "SecurityPolicyValue", "ParameterValue": "SecurityPolicy_TLS13_1_3_2025_09"}, | ||
| {"ParameterKey": "EndpointAccessModeValue", "ParameterValue": "BASIC"}, | ||
| ] | ||
| self.update_stack(parameters=update_parameters) | ||
|
|
||
| rest_api = self.client_provider.api_client.get_rest_api(restApiId=rest_api_id) | ||
|
|
||
| self.assertEqual(rest_api["securityPolicy"], "SecurityPolicy_TLS13_1_3_2025_09") | ||
| self.assertEqual(rest_api["endpointAccessMode"], "BASIC") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.