Created
July 17, 2017 10:28
-
-
Save wolfeidau/7deae99e3b06255240bbd07dc26c3cc6 to your computer and use it in GitHub Desktop.
SAM deployment file for cognito API
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
| AWSTemplateFormatVersion: '2010-09-09' | |
| Transform: AWS::Serverless-2016-10-31 | |
| Parameters: | |
| EnvironmentName: | |
| Type: String | |
| EnvironmentNumber: | |
| Type: String | |
| CognitoUserPoolArn: | |
| Type: String | |
| Resources: | |
| ApiGatewayApi: | |
| Type: AWS::Serverless::Api | |
| Properties: | |
| StageName: Prod | |
| DefinitionBody: | |
| swagger: 2.0 | |
| info: | |
| title: cognito-api-lambda-dev-1 | |
| basePath: /prod | |
| schemes: | |
| - https | |
| paths: | |
| /: | |
| x-amazon-apigateway-any-method: | |
| produces: | |
| - application/json | |
| responses: | |
| "200": | |
| description: 200 response | |
| schema: | |
| $ref: "#/definitions/Empty" | |
| security: | |
| - myApiUsers: [] | |
| x-amazon-apigateway-integration: | |
| responses: | |
| default: | |
| statusCode: "200" | |
| uri: | |
| Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${Function.Arn}/invocations | |
| passthroughBehavior: when_no_match | |
| httpMethod: POST | |
| type: aws_proxy | |
| options: | |
| consumes: | |
| - application/json | |
| produces: | |
| - application/json | |
| responses: | |
| "200": | |
| description: 200 response | |
| schema: | |
| $ref: "#/definitions/Empty" | |
| headers: | |
| Access-Control-Allow-Origin: | |
| type: string | |
| Access-Control-Allow-Methods: | |
| type: string | |
| Access-Control-Allow-Headers: | |
| type: string | |
| x-amazon-apigateway-integration: | |
| responses: | |
| default: | |
| statusCode: "200" | |
| responseParameters: | |
| method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" | |
| method.response.header.Access-Control-Allow-Headers: "'Content-Type,Authorization,X-Amz-Date,X-Api-Key,X-Amz-Security-Token'" | |
| method.response.header.Access-Control-Allow-Origin: "'*'" | |
| passthroughBehavior: when_no_match | |
| requestTemplates: | |
| application/json: "{\"statusCode\": 200}" | |
| type: mock | |
| /{proxy+}: | |
| x-amazon-apigateway-any-method: | |
| produces: | |
| - application/json | |
| parameters: | |
| - name: proxy | |
| in: path | |
| required: true | |
| type: string | |
| responses: {} | |
| security: | |
| - myApiUsers: [] | |
| x-amazon-apigateway-integration: | |
| uri: | |
| Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${Function.Arn}/invocations | |
| httpMethod: POST | |
| type: aws_proxy | |
| options: | |
| consumes: | |
| - application/json | |
| produces: | |
| - application/json | |
| responses: | |
| "200": | |
| description: 200 response | |
| schema: | |
| $ref: "#/definitions/Empty" | |
| headers: | |
| Access-Control-Allow-Origin: | |
| type: string | |
| Access-Control-Allow-Methods: | |
| type: string | |
| Access-Control-Allow-Headers: | |
| type: string | |
| x-amazon-apigateway-integration: | |
| responses: | |
| default: | |
| statusCode: "200" | |
| responseParameters: | |
| method.response.header.Access-Control-Allow-Methods: "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'" | |
| method.response.header.Access-Control-Allow-Headers: "'Content-Type,Authorization,X-Amz-Date,X-Api-Key,X-Amz-Security-Token'" | |
| method.response.header.Access-Control-Allow-Origin: "'*'" | |
| passthroughBehavior: when_no_match | |
| requestTemplates: | |
| application/json: "{\"statusCode\": 200}" | |
| type: mock | |
| x-amazon-apigateway-binary-media-types: | |
| - multipart/form-data # Support POST of multi part forms containing binary data (images) | |
| - application/octet-stream | |
| - image/jpeg | |
| - image/png | |
| - image/svg+xml | |
| securityDefinitions: | |
| myApiUsers: | |
| type: "apiKey" | |
| name: "Authorization" | |
| in: "header" | |
| x-amazon-apigateway-authtype: "cognito_user_pools" | |
| x-amazon-apigateway-authorizer: | |
| providerARNs: | |
| - Fn::Sub: ${CognitoUserPoolArn} | |
| type: "cognito_user_pools" | |
| definitions: | |
| Empty: | |
| type: object | |
| title: Empty Schema | |
| Variables: | |
| LambdaFunctionName: !Ref Function | |
| Function: | |
| Type: AWS::Serverless::Function | |
| Properties: | |
| Handler: index.handler | |
| Runtime: nodejs6.10 | |
| CodeUri: ./handler.zip | |
| MemorySize: 512 | |
| Timeout: 30 | |
| # These policies will get you started but you really need to | |
| # be more specific! | |
| Policies: | |
| - AWSLambdaBasicExecutionRole | |
| - AWSXrayWriteOnlyAccess | |
| - AmazonSSMFullAccess | |
| Environment: | |
| Variables: | |
| ENVIRONMENT_NAME: | |
| Ref: EnvironmentName | |
| ENVIRONMENT_NUMBER: | |
| Ref: EnvironmentNumber | |
| Events: | |
| ApiRoot: | |
| Type: Api | |
| Properties: | |
| RestApiId: !Ref ApiGatewayApi | |
| Path: / | |
| Method: ANY | |
| ApiGreedy: | |
| Type: Api | |
| Properties: | |
| RestApiId: !Ref ApiGatewayApi | |
| Path: /{proxy+} | |
| Method: ANY | |
| Outputs: | |
| URL: | |
| Value: !Sub "https://${ApiGatewayApi}.execute-api.${AWS::Region}.amazonaws.com/Prod" | |
| FunctionArn: | |
| Value: !GetAtt Function.Arn | |
| Export: | |
| Name: !Sub "${AWS::StackName}-FunctionArn" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment