-
-
Notifications
You must be signed in to change notification settings - Fork 81
feat(rest-api): SecurityPolicy & EndpointAccessMode support #144
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
Changes from all commits
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -739,6 +739,43 @@ provider: | |||||
| - vpce-456 | ||||||
| ``` | ||||||
|
|
||||||
| ### Security Policy | ||||||
|
|
||||||
| You can configure the TLS version for your API Gateway REST API by setting the `securityPolicy` property under `apiGateway` in the `provider` block. This maps directly to the [SecurityPolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-apigateway-restapi.html#cfn-apigateway-restapi-securitypolicy) property of the `AWS::ApiGateway::RestApi` CloudFormation resource. | ||||||
| Specific explanation about Security Policy types and structure can be found [here](https://aws.amazon.com/blogs/compute/enhancing-api-security-with-amazon-api-gateway-tls-security-policies/) | ||||||
|
|
||||||
| ```yml | ||||||
| service: my-service | ||||||
| provider: | ||||||
| name: aws | ||||||
| apiGateway: | ||||||
| securityPolicy: TLS_1_2 | ||||||
| functions: | ||||||
| hello: | ||||||
| events: | ||||||
| - http: | ||||||
| path: user/create | ||||||
| method: get | ||||||
| ``` | ||||||
|
|
||||||
| ### Endpoint Access Mode | ||||||
|
|
||||||
| You can control how clients access your API Gateway endpoint by setting the `endpointAccessMode` property under `apiGateway` in the `provider` block. Valid values are `STRICT` and `BASIC`. This maps directly to the [EndpointAccessMode](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-apigateway-restapi.html#cfn-apigateway-restapi-endpointaccessmode) property of the `AWS::ApiGateway::RestApi` CloudFormation resource. According to AWS documentation, if a security policy is configured with a legacy template (that doesn't have the `SecurityPolicy_` prefix) access Mode should be empty) | ||||||
|
||||||
| You can control how clients access your API Gateway endpoint by setting the `endpointAccessMode` property under `apiGateway` in the `provider` block. Valid values are `STRICT` and `BASIC`. This maps directly to the [EndpointAccessMode](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-apigateway-restapi.html#cfn-apigateway-restapi-endpointaccessmode) property of the `AWS::ApiGateway::RestApi` CloudFormation resource. According to AWS documentation, if a security policy is configured with a legacy template (that doesn't have the `SecurityPolicy_` prefix) access Mode should be empty) | |
| You can control how clients access your API Gateway endpoint by setting the `endpointAccessMode` property under `apiGateway` in the `provider` block. Valid values are `STRICT` and `BASIC`. This maps directly to the [EndpointAccessMode](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-apigateway-restapi.html#cfn-apigateway-restapi-endpointaccessmode) property of the `AWS::ApiGateway::RestApi` CloudFormation resource. According to AWS documentation, if a security policy is configured with a legacy template (that does not have the `SecurityPolicy_` prefix), access mode should be empty. |
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -17,10 +17,20 @@ module.exports = { | |||||||||||||||
| let endpointType = 'EDGE'; | ||||||||||||||||
| let vpcEndpointIds; | ||||||||||||||||
| let BinaryMediaTypes; | ||||||||||||||||
| let SecurityPolicy; | ||||||||||||||||
| let EndpointAccessMode; | ||||||||||||||||
| if (apiGateway.binaryMediaTypes) { | ||||||||||||||||
| BinaryMediaTypes = apiGateway.binaryMediaTypes; | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| if (apiGateway.securityPolicy) { | ||||||||||||||||
| SecurityPolicy = apiGateway.securityPolicy; | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| if (apiGateway.endpointAccessMode) { | ||||||||||||||||
| EndpointAccessMode = apiGateway.endpointAccessMode.toUpperCase(); | ||||||||||||||||
|
Comment on lines
+30
to
+31
|
||||||||||||||||
| if (apiGateway.endpointAccessMode) { | |
| EndpointAccessMode = apiGateway.endpointAccessMode.toUpperCase(); | |
| if (apiGateway.endpointAccessMode != null) { | |
| EndpointAccessMode = | |
| apiGateway.endpointAccessMode === '' | |
| ? apiGateway.endpointAccessMode | |
| : apiGateway.endpointAccessMode.toUpperCase(); |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -848,6 +848,12 @@ class AwsProvider { | |||||
| type: 'array', | ||||||
| items: { type: 'string', pattern: '^\\S+\\/\\S+$' }, | ||||||
| }, | ||||||
| securityPolicy: { | ||||||
| type: 'string', | ||||||
| }, | ||||||
| endpointAccessMode: { | ||||||
| anyOf: ['strict', 'basic', ''].map(caseInsensitive), | ||||||
|
||||||
| anyOf: ['strict', 'basic', ''].map(caseInsensitive), | |
| anyOf: ['strict', 'basic'].map(caseInsensitive), |
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.
Missing ending punctuation and an article: this sentence reads unpolished in the docs. Consider changing it to “A specific explanation of security policy types and structure can be found here: …” (and end with a period).