--- # Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy of this # software and associated documentation files (the "Software"), to deal in the Software # without restriction, including without limitation the rights to use, copy, modify, # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. AWSTemplateFormatVersion: 2010-09-09 Description: AWS SaaS Factory Serverless SaaS Workshop - Lab 3 Parameters: LoadBalancerDNS: Description: Application Load Balancer DNS name for API Gateway to proxy Type: String TenantServiceGetAllArn: Description: TenantService getByAll function ARN Type: String TenantServiceGetByIdArn: Description: TenantService getById function ARN Type: String TenantServiceUpdateArn: Description: TenantService update function ARN Type: String TenantServiceInsertArn: Description: TenantService insert function ARN Type: String TenantServiceDeleteArn: Description: TenantService delete function ARN Type: String TenantServiceNextDbArn: Description: TenantService nextDb function ARN Type: String TenantServiceUpdateUserPoolArn: Description: TenantService updateUserPool function ARN Type: String RegistrationServiceRegisterArn: Description: RegistrationService register function ARN Type: String AuthServiceSignInArn: Description: AuthService sign in function ARN Type: String LambdaCustomAuthorizerArn: Description: API Gateway Lambda authorizer function ARN Type: String ApiGatewayLambdaAuthorizerRoleArn: Description: IAM execution role for the API Gateway Lambda authorizer Type: String LambdaWarmerArn: Description: Lambda warmer function ARN Type: String WorkshopS3Bucket: Description: S3 bucket where you uploaded the Lambda function and layers code packages Type: String #Metadata: Resources: OrderServiceExecutionRole: Type: AWS::IAM::Role Properties: RoleName: !Sub saas-factory-srvls-wrkshp-ordersvc-lambda-role-${AWS::Region} Path: '/' AssumeRolePolicyDocument: Version: 2012-10-17 Statement: - Effect: Allow Principal: Service: - lambda.amazonaws.com Action: - sts:AssumeRole Policies: - PolicyName: !Sub saas-factory-srvls-wrkshp-ordersvc-lambda-policy-${AWS::Region} PolicyDocument: Version: 2012-10-17 Statement: - Effect: Allow Action: - logs:PutLogEvents Resource: !Sub arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:*:log-stream:* - Effect: Allow Action: - logs:CreateLogStream - logs:DescribeLogStreams Resource: - !Sub arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:* - Effect: Allow Action: - dynamodb:ListTables Resource: '*' - Effect: Allow Action: - dynamodb:CreateTable - dynamodb:DescribeTable - dynamodb:GetItem - dynamodb:PutItem - dynamodb:DeleteItem - dynamodb:Scan - dynamodb:Query - dynamodb:UpdateItem Resource: !Sub arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/* - Effect: Allow Action: - cognito-idp:ListUserPools Resource: '*' OrderServiceGetByIdLogs: Type: AWS::Logs::LogGroup Properties: LogGroupName: !Sub /aws/lambda/saas-factory-srvls-wrkshp-orders-get-by-id-${AWS::Region} RetentionInDays: 30 OrderServiceGetById: Type: AWS::Lambda::Function Properties: FunctionName: !Sub saas-factory-srvls-wrkshp-orders-get-by-id-${AWS::Region} Role: !GetAtt OrderServiceExecutionRole.Arn Runtime: java8 Timeout: 30 MemorySize: 1024 Handler: com.amazon.aws.partners.saasfactory.OrderService::getOrder Code: S3Bucket: !Ref WorkshopS3Bucket S3Key: OrderService-lambda.zip OrderServiceGetAllLogs: Type: AWS::Logs::LogGroup Properties: LogGroupName: !Sub /aws/lambda/saas-factory-srvls-wrkshp-orders-get-all-${AWS::Region} RetentionInDays: 30 OrderServiceGetAll: Type: AWS::Lambda::Function Properties: FunctionName: !Sub saas-factory-srvls-wrkshp-orders-get-all-${AWS::Region} Role: !GetAtt OrderServiceExecutionRole.Arn Runtime: java8 Timeout: 30 MemorySize: 1024 Handler: com.amazon.aws.partners.saasfactory.OrderService::getOrders Code: S3Bucket: !Ref WorkshopS3Bucket S3Key: OrderService-lambda.zip OrderServiceUpdateLogs: Type: AWS::Logs::LogGroup Properties: LogGroupName: !Sub /aws/lambda/saas-factory-srvls-wrkshp-orders-update-${AWS::Region} RetentionInDays: 30 OrderServiceUpdate: Type: AWS::Lambda::Function Properties: FunctionName: !Sub saas-factory-srvls-wrkshp-orders-update-${AWS::Region} Role: !GetAtt OrderServiceExecutionRole.Arn Runtime: java8 Timeout: 30 MemorySize: 1024 Handler: com.amazon.aws.partners.saasfactory.OrderService::updateOrder Code: S3Bucket: !Ref WorkshopS3Bucket S3Key: OrderService-lambda.zip OrderServiceInsertLogs: Type: AWS::Logs::LogGroup Properties: LogGroupName: !Sub /aws/lambda/saas-factory-srvls-wrkshp-orders-insert-${AWS::Region} RetentionInDays: 30 OrderServiceInsert: Type: AWS::Lambda::Function Properties: FunctionName: !Sub saas-factory-srvls-wrkshp-orders-insert-${AWS::Region} Role: !GetAtt OrderServiceExecutionRole.Arn Runtime: java8 Timeout: 30 MemorySize: 1024 Handler: com.amazon.aws.partners.saasfactory.OrderService::insertOrder Code: S3Bucket: !Ref WorkshopS3Bucket S3Key: OrderService-lambda.zip OrderServiceDeleteLogs: Type: AWS::Logs::LogGroup Properties: LogGroupName: !Sub /aws/lambda/saas-factory-srvls-wrkshp-orders-delete-${AWS::Region} RetentionInDays: 30 OrderServiceDelete: Type: AWS::Lambda::Function Properties: FunctionName: !Sub saas-factory-srvls-wrkshp-orders-delete-${AWS::Region} Role: !GetAtt OrderServiceExecutionRole.Arn Runtime: java8 Timeout: 30 MemorySize: 1024 Handler: com.amazon.aws.partners.saasfactory.OrderService::deleteOrder Code: S3Bucket: !Ref WorkshopS3Bucket S3Key: OrderService-lambda.zip ApiGatewayLoggingRole: Type: AWS::IAM::Role Properties: RoleName: !Sub saas-factory-srvls-wrkshp-apigw-log-lab3-role-${AWS::Region} Path: '/' AssumeRolePolicyDocument: Version: 2012-10-17 Statement: - Effect: Allow Principal: Service: - apigateway.amazonaws.com Action: - sts:AssumeRole ManagedPolicyArns: - arn:aws:iam::aws:policy/service-role/AmazonAPIGatewayPushToCloudWatchLogs ApiGatewayLab3Api: Type: AWS::ApiGateway::RestApi Properties: Name: saas-factory-srvls-wrkshp-lab3 EndpointConfiguration: Types: [REGIONAL] ApiGatewayLoggingAccount: Type: AWS::ApiGateway::Account DependsOn: - ApiGatewayLab3Api - ApiGatewayLoggingRole Properties: CloudWatchRoleArn: !GetAtt ApiGatewayLoggingRole.Arn ApiGatewayLambdaAuthorizer: Type: AWS::ApiGateway::Authorizer Properties: RestApiId: !Ref ApiGatewayLab3Api Type: TOKEN Name: !Sub saas-factory-srvls-wrkshp-apigw-lambda-authorizer-lab3-${AWS::Region} AuthorizerCredentials: !Ref ApiGatewayLambdaAuthorizerRoleArn IdentitySource: method.request.header.Authorization IdentityValidationExpression: ^[Bb]earer [A-Za-z0-9-_=]+\.[A-Za-z0-9-_=]+\.?[A-Za-z0-9-_.+/=]*$ AuthorizerUri: !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${LambdaCustomAuthorizerArn}/invocations ProductServiceProductsResource: Type: AWS::ApiGateway::Resource Properties: RestApiId: !Ref ApiGatewayLab3Api ParentId: !GetAtt ApiGatewayLab3Api.RootResourceId PathPart: products ProductServiceProductByIdResource: Type: AWS::ApiGateway::Resource Properties: RestApiId: !Ref ApiGatewayLab3Api ParentId: !Ref ProductServiceProductsResource PathPart: '{id}' ProductServiceCategoriesResource: Type: AWS::ApiGateway::Resource Properties: RestApiId: !Ref ApiGatewayLab3Api ParentId: !GetAtt ApiGatewayLab3Api.RootResourceId PathPart: categories ProductServiceCategoryByIdResource: Type: AWS::ApiGateway::Resource Properties: RestApiId: !Ref ApiGatewayLab3Api ParentId: !Ref ProductServiceCategoriesResource PathPart: '{id}' OrderServiceOrdersResource: Type: AWS::ApiGateway::Resource Properties: RestApiId: !Ref ApiGatewayLab3Api ParentId: !GetAtt ApiGatewayLab3Api.RootResourceId PathPart: orders OrderServiceByIdResource: Type: AWS::ApiGateway::Resource Properties: RestApiId: !Ref ApiGatewayLab3Api ParentId: !Ref OrderServiceOrdersResource PathPart: '{id}' ProductServiceProductsResourceCORS: Type: AWS::ApiGateway::Method Properties: RestApiId: !Ref ApiGatewayLab3Api ResourceId: !Ref ProductServiceProductsResource HttpMethod: OPTIONS AuthorizationType: NONE Integration: Type: MOCK PassthroughBehavior: WHEN_NO_MATCH IntegrationResponses: - StatusCode: 200 ResponseTemplates: {application/json: ''} ResponseParameters: method.response.header.Access-Control-Allow-Headers: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'" method.response.header.Access-Control-Allow-Methods: "'GET,POST,OPTIONS'" method.response.header.Access-Control-Allow-Origin: "'*'" method.response.header.Access-Control-Max-Age: "'3600'" method.response.header.X-Requested-With: "'*'" RequestTemplates: application/json: '{"statusCode": 200}' MethodResponses: - StatusCode: 200 ResponseModels: {application/json: Empty} ResponseParameters: method.response.header.Access-Control-Allow-Headers: false method.response.header.Access-Control-Allow-Methods: false method.response.header.Access-Control-Allow-Origin: false method.response.header.Access-Control-Max-Age: false method.response.header.X-Requested-With: false ProductServiceProductByIdResourceCORS: Type: AWS::ApiGateway::Method Properties: RestApiId: !Ref ApiGatewayLab3Api ResourceId: !Ref ProductServiceProductByIdResource HttpMethod: OPTIONS AuthorizationType: NONE Integration: Type: MOCK PassthroughBehavior: WHEN_NO_MATCH IntegrationResponses: - StatusCode: 200 ResponseTemplates: {application/json: ''} ResponseParameters: method.response.header.Access-Control-Allow-Headers: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'" method.response.header.Access-Control-Allow-Methods: "'GET,PUT,DELETE,OPTIONS,POST'" method.response.header.Access-Control-Allow-Origin: "'*'" method.response.header.Access-Control-Max-Age: "'3600'" method.response.header.X-Requested-With: "'*'" RequestTemplates: application/json: '{"statusCode": 200}' MethodResponses: - StatusCode: 200 ResponseModels: {application/json: Empty} ResponseParameters: method.response.header.Access-Control-Allow-Headers: false method.response.header.Access-Control-Allow-Methods: false method.response.header.Access-Control-Allow-Origin: false method.response.header.Access-Control-Max-Age: false method.response.header.X-Requested-With: false ProductServiceCategoriesResourceCORS: Type: AWS::ApiGateway::Method Properties: RestApiId: !Ref ApiGatewayLab3Api ResourceId: !Ref ProductServiceCategoriesResource HttpMethod: OPTIONS AuthorizationType: NONE Integration: Type: MOCK PassthroughBehavior: WHEN_NO_MATCH IntegrationResponses: - StatusCode: 200 ResponseTemplates: {application/json: ''} ResponseParameters: method.response.header.Access-Control-Allow-Headers: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'" method.response.header.Access-Control-Allow-Methods: "'GET,POST,OPTIONS'" method.response.header.Access-Control-Allow-Origin: "'*'" method.response.header.Access-Control-Max-Age: "'3600'" method.response.header.X-Requested-With: "'*'" RequestTemplates: application/json: '{"statusCode": 200}' MethodResponses: - StatusCode: 200 ResponseModels: {application/json: Empty} ResponseParameters: method.response.header.Access-Control-Allow-Headers: false method.response.header.Access-Control-Allow-Methods: false method.response.header.Access-Control-Allow-Origin: false method.response.header.Access-Control-Max-Age: false method.response.header.X-Requested-With: false ProductServiceCategoryByIdResourceCORS: Type: AWS::ApiGateway::Method Properties: RestApiId: !Ref ApiGatewayLab3Api ResourceId: !Ref ProductServiceCategoryByIdResource HttpMethod: OPTIONS AuthorizationType: NONE Integration: Type: MOCK PassthroughBehavior: WHEN_NO_MATCH IntegrationResponses: - StatusCode: 200 ResponseTemplates: {application/json: ''} ResponseParameters: method.response.header.Access-Control-Allow-Headers: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'" method.response.header.Access-Control-Allow-Methods: "'GET,PUT,DELETE,OPTIONS,POST'" method.response.header.Access-Control-Allow-Origin: "'*'" method.response.header.Access-Control-Max-Age: "'3600'" method.response.header.X-Requested-With: "'*'" RequestTemplates: application/json: '{"statusCode": 200}' MethodResponses: - StatusCode: 200 ResponseModels: {application/json: Empty} ResponseParameters: method.response.header.Access-Control-Allow-Headers: false method.response.header.Access-Control-Allow-Methods: false method.response.header.Access-Control-Allow-Origin: false method.response.header.Access-Control-Max-Age: false method.response.header.X-Requested-With: false ProductServiceGetAllMethod: Type: AWS::ApiGateway::Method Properties: RestApiId: !Ref ApiGatewayLab3Api ResourceId: !Ref ProductServiceProductsResource AuthorizationType: CUSTOM AuthorizerId: !Ref ApiGatewayLambdaAuthorizer HttpMethod: GET Integration: Type: HTTP IntegrationHttpMethod: GET Uri: !Sub http://${LoadBalancerDNS}/api/products PassthroughBehavior: WHEN_NO_MATCH RequestParameters: {integration.request.header.X-Tenant-ID: 'context.authorizer.TenantId'} IntegrationResponses: - StatusCode: 200 ResponseTemplates: {application/json: ''} ResponseParameters: method.response.header.Access-Control-Allow-Origin: "'*'" MethodResponses: - StatusCode: 200 ResponseModels: {application/json: Empty} ResponseParameters: method.response.header.Access-Control-Allow-Origin: false ProductServiceGetByIdMethod: Type: AWS::ApiGateway::Method Properties: RestApiId: !Ref ApiGatewayLab3Api ResourceId: !Ref ProductServiceProductByIdResource AuthorizationType: CUSTOM AuthorizerId: !Ref ApiGatewayLambdaAuthorizer HttpMethod: GET RequestParameters: {method.request.path.id: true} Integration: Type: HTTP IntegrationHttpMethod: GET Uri: !Sub http://${LoadBalancerDNS}/api/products/{id} PassthroughBehavior: WHEN_NO_MATCH RequestParameters: {integration.request.path.id: 'method.request.path.id'} RequestParameters: {integration.request.header.X-Tenant-ID: 'context.authorizer.TenantId'} IntegrationResponses: - StatusCode: 200 ResponseTemplates: {application/json: ''} ResponseParameters: method.response.header.Access-Control-Allow-Origin: "'*'" MethodResponses: - StatusCode: 200 ResponseModels: {application/json: Empty} ResponseParameters: method.response.header.Access-Control-Allow-Origin: false ProductServiceUpdateMethod: Type: AWS::ApiGateway::Method Properties: RestApiId: !Ref ApiGatewayLab3Api ResourceId: !Ref ProductServiceProductByIdResource AuthorizationType: CUSTOM AuthorizerId: !Ref ApiGatewayLambdaAuthorizer HttpMethod: PUT RequestParameters: {method.request.path.id: true} Integration: Type: HTTP IntegrationHttpMethod: PUT Uri: !Sub http://${LoadBalancerDNS}/api/products/{id} PassthroughBehavior: WHEN_NO_MATCH RequestParameters: {integration.request.path.id: 'method.request.path.id'} RequestParameters: {integration.request.header.X-Tenant-ID: 'context.authorizer.TenantId'} IntegrationResponses: - StatusCode: 200 ResponseTemplates: {application/json: ''} ResponseParameters: method.response.header.Access-Control-Allow-Origin: "'*'" MethodResponses: - StatusCode: 200 ResponseModels: {application/json: Empty} ResponseParameters: method.response.header.Access-Control-Allow-Origin: false ProductServiceInsertMethod: Type: AWS::ApiGateway::Method Properties: RestApiId: !Ref ApiGatewayLab3Api ResourceId: !Ref ProductServiceProductsResource AuthorizationType: CUSTOM AuthorizerId: !Ref ApiGatewayLambdaAuthorizer HttpMethod: POST Integration: Type: HTTP IntegrationHttpMethod: POST Uri: !Sub http://${LoadBalancerDNS}/api/products PassthroughBehavior: WHEN_NO_MATCH RequestParameters: {integration.request.header.X-Tenant-ID: 'context.authorizer.TenantId'} IntegrationResponses: - StatusCode: 200 ResponseTemplates: {application/json: ''} ResponseParameters: method.response.header.Access-Control-Allow-Origin: "'*'" MethodResponses: - StatusCode: 200 ResponseModels: {application/json: Empty} ResponseParameters: method.response.header.Access-Control-Allow-Origin: false ProductServiceDeleteMethod: Type: AWS::ApiGateway::Method Properties: RestApiId: !Ref ApiGatewayLab3Api ResourceId: !Ref ProductServiceProductByIdResource AuthorizationType: CUSTOM AuthorizerId: !Ref ApiGatewayLambdaAuthorizer HttpMethod: DELETE RequestParameters: {method.request.path.id: true} Integration: Type: HTTP IntegrationHttpMethod: DELETE Uri: !Sub http://${LoadBalancerDNS}/api/products/{id} PassthroughBehavior: WHEN_NO_MATCH RequestParameters: {integration.request.path.id: 'method.request.path.id'} RequestParameters: {integration.request.header.X-Tenant-ID: 'context.authorizer.TenantId'} IntegrationResponses: - StatusCode: 200 ResponseTemplates: {application/json: ''} ResponseParameters: method.response.header.Access-Control-Allow-Origin: "'*'" MethodResponses: - StatusCode: 200 ResponseModels: {application/json: Empty} ResponseParameters: method.response.header.Access-Control-Allow-Origin: false ProductServiceGetAllCategoriesMethod: Type: AWS::ApiGateway::Method Properties: RestApiId: !Ref ApiGatewayLab3Api ResourceId: !Ref ProductServiceCategoriesResource AuthorizationType: CUSTOM AuthorizerId: !Ref ApiGatewayLambdaAuthorizer HttpMethod: GET Integration: Type: HTTP IntegrationHttpMethod: GET Uri: !Sub http://${LoadBalancerDNS}/api/categories PassthroughBehavior: WHEN_NO_MATCH RequestParameters: {integration.request.header.X-Tenant-ID: 'context.authorizer.TenantId'} IntegrationResponses: - StatusCode: 200 ResponseTemplates: {application/json: ''} ResponseParameters: method.response.header.Access-Control-Allow-Origin: "'*'" MethodResponses: - StatusCode: 200 ResponseModels: {application/json: Empty} ResponseParameters: method.response.header.Access-Control-Allow-Origin: false ProductServiceGetCategoryByIdMethod: Type: AWS::ApiGateway::Method Properties: RestApiId: !Ref ApiGatewayLab3Api ResourceId: !Ref ProductServiceCategoryByIdResource AuthorizationType: CUSTOM AuthorizerId: !Ref ApiGatewayLambdaAuthorizer HttpMethod: GET RequestParameters: {method.request.path.id: true} Integration: Type: HTTP IntegrationHttpMethod: GET Uri: !Sub http://${LoadBalancerDNS}/api/categories/{id} PassthroughBehavior: WHEN_NO_MATCH RequestParameters: {integration.request.path.id: 'method.request.path.id'} RequestParameters: {integration.request.header.X-Tenant-ID: 'context.authorizer.TenantId'} IntegrationResponses: - StatusCode: 200 ResponseTemplates: {application/json: ''} ResponseParameters: method.response.header.Access-Control-Allow-Origin: "'*'" MethodResponses: - StatusCode: 200 ResponseModels: {application/json: Empty} ResponseParameters: method.response.header.Access-Control-Allow-Origin: false ProductServiceUpdateCategoryMethod: Type: AWS::ApiGateway::Method Properties: RestApiId: !Ref ApiGatewayLab3Api ResourceId: !Ref ProductServiceCategoryByIdResource AuthorizationType: CUSTOM AuthorizerId: !Ref ApiGatewayLambdaAuthorizer HttpMethod: PUT RequestParameters: {method.request.path.id: true} Integration: Type: HTTP IntegrationHttpMethod: PUT Uri: !Sub http://${LoadBalancerDNS}/api/categories/{id} PassthroughBehavior: WHEN_NO_MATCH RequestParameters: {integration.request.path.id: 'method.request.path.id'} RequestParameters: {integration.request.header.X-Tenant-ID: 'context.authorizer.TenantId'} IntegrationResponses: - StatusCode: 200 ResponseTemplates: {application/json: ''} ResponseParameters: method.response.header.Access-Control-Allow-Origin: "'*'" MethodResponses: - StatusCode: 200 ResponseModels: {application/json: Empty} ResponseParameters: method.response.header.Access-Control-Allow-Origin: false ProductServiceInsertCategoryMethod: Type: AWS::ApiGateway::Method Properties: RestApiId: !Ref ApiGatewayLab3Api ResourceId: !Ref ProductServiceCategoriesResource AuthorizationType: CUSTOM AuthorizerId: !Ref ApiGatewayLambdaAuthorizer HttpMethod: POST Integration: Type: HTTP IntegrationHttpMethod: POST Uri: !Sub http://${LoadBalancerDNS}/api/categories PassthroughBehavior: WHEN_NO_MATCH RequestParameters: {integration.request.header.X-Tenant-ID: 'context.authorizer.TenantId'} IntegrationResponses: - StatusCode: 200 ResponseTemplates: {application/json: ''} ResponseParameters: method.response.header.Access-Control-Allow-Origin: "'*'" MethodResponses: - StatusCode: 200 ResponseModels: {application/json: Empty} ResponseParameters: method.response.header.Access-Control-Allow-Origin: false ProductServiceDeleteCategoryMethod: Type: AWS::ApiGateway::Method Properties: RestApiId: !Ref ApiGatewayLab3Api ResourceId: !Ref ProductServiceCategoryByIdResource AuthorizationType: CUSTOM AuthorizerId: !Ref ApiGatewayLambdaAuthorizer HttpMethod: DELETE RequestParameters: {method.request.path.id: true} Integration: Type: HTTP IntegrationHttpMethod: DELETE Uri: !Sub http://${LoadBalancerDNS}/api/categories/{id} PassthroughBehavior: WHEN_NO_MATCH RequestParameters: {integration.request.path.id: 'method.request.path.id'} RequestParameters: {integration.request.header.X-Tenant-ID: 'context.authorizer.TenantId'} IntegrationResponses: - StatusCode: 200 ResponseTemplates: {application/json: ''} ResponseParameters: method.response.header.Access-Control-Allow-Origin: "'*'" MethodResponses: - StatusCode: 200 ResponseModels: {application/json: Empty} ResponseParameters: method.response.header.Access-Control-Allow-Origin: false OrderServiceOrdersResourceCORS: Type: AWS::ApiGateway::Method Properties: RestApiId: !Ref ApiGatewayLab3Api ResourceId: !Ref OrderServiceOrdersResource HttpMethod: OPTIONS AuthorizationType: NONE Integration: Type: MOCK PassthroughBehavior: WHEN_NO_MATCH IntegrationResponses: - StatusCode: 200 ResponseTemplates: {application/json: ''} ResponseParameters: method.response.header.Access-Control-Allow-Headers: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'" method.response.header.Access-Control-Allow-Methods: "'GET,POST,OPTIONS'" method.response.header.Access-Control-Allow-Origin: "'*'" method.response.header.Access-Control-Max-Age: "'3600'" method.response.header.X-Requested-With: "'*'" RequestTemplates: application/json: '{"statusCode": 200}' MethodResponses: - StatusCode: 200 ResponseModels: {application/json: Empty} ResponseParameters: method.response.header.Access-Control-Allow-Headers: false method.response.header.Access-Control-Allow-Methods: false method.response.header.Access-Control-Allow-Origin: false method.response.header.Access-Control-Max-Age: false method.response.header.X-Requested-With: false OrderServiceOrderByIdResourceCORS: Type: AWS::ApiGateway::Method Properties: RestApiId: !Ref ApiGatewayLab3Api ResourceId: !Ref OrderServiceByIdResource HttpMethod: OPTIONS AuthorizationType: NONE Integration: Type: MOCK PassthroughBehavior: WHEN_NO_MATCH IntegrationResponses: - StatusCode: 200 ResponseTemplates: {application/json: ''} ResponseParameters: method.response.header.Access-Control-Allow-Headers: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'" method.response.header.Access-Control-Allow-Methods: "'GET,PUT,DELETE,OPTIONS,POST'" method.response.header.Access-Control-Allow-Origin: "'*'" method.response.header.Access-Control-Max-Age: "'3600'" method.response.header.X-Requested-With: "'*'" RequestTemplates: application/json: '{"statusCode": 200}' MethodResponses: - StatusCode: 200 ResponseModels: {application/json: Empty} ResponseParameters: method.response.header.Access-Control-Allow-Headers: false method.response.header.Access-Control-Allow-Methods: false method.response.header.Access-Control-Allow-Origin: false method.response.header.Access-Control-Max-Age: false method.response.header.X-Requested-With: false OrderServiceGetAllMethod: Type: AWS::ApiGateway::Method Properties: RestApiId: !Ref ApiGatewayLab3Api ResourceId: !Ref OrderServiceOrdersResource HttpMethod: GET AuthorizationType: NONE Integration: Type: AWS_PROXY IntegrationHttpMethod: POST Uri: !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${OrderServiceGetAll.Arn}/invocations PassthroughBehavior: WHEN_NO_MATCH IntegrationResponses: - StatusCode: 200 ResponseTemplates: {application/json: ''} ResponseParameters: method.response.header.Access-Control-Allow-Origin: "'*'" MethodResponses: - StatusCode: 200 ResponseModels: {application/json: Empty} ResponseParameters: method.response.header.Access-Control-Allow-Origin: false OrderServiceGetAllLambdaPermission: Type: AWS::Lambda::Permission Properties: Principal: apigateway.amazonaws.com Action: lambda:InvokeFunction FunctionName: !GetAtt OrderServiceGetAll.Arn SourceArn: !Sub arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${ApiGatewayLab3Api}/*/GET/orders OrderServiceGetByIdMethod: Type: AWS::ApiGateway::Method Properties: RestApiId: !Ref ApiGatewayLab3Api ResourceId: !Ref OrderServiceByIdResource HttpMethod: GET AuthorizationType: NONE RequestParameters: {method.request.path.id: true} Integration: Type: AWS_PROXY IntegrationHttpMethod: POST Uri: !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${OrderServiceGetById.Arn}/invocations PassthroughBehavior: WHEN_NO_MATCH RequestParameters: {integration.request.path.id: 'method.request.path.id'} IntegrationResponses: - StatusCode: 200 ResponseTemplates: {application/json: ''} ResponseParameters: method.response.header.Access-Control-Allow-Origin: "'*'" MethodResponses: - StatusCode: 200 ResponseModels: {application/json: Empty} ResponseParameters: method.response.header.Access-Control-Allow-Origin: false OrderServiceGetByIdLambdaPermission: Type: AWS::Lambda::Permission Properties: Principal: apigateway.amazonaws.com Action: lambda:InvokeFunction FunctionName: !GetAtt OrderServiceGetById.Arn SourceArn: !Sub arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${ApiGatewayLab3Api}/*/GET/orders/{id} OrderServiceUpdateMethod: Type: AWS::ApiGateway::Method Properties: RestApiId: !Ref ApiGatewayLab3Api ResourceId: !Ref OrderServiceByIdResource HttpMethod: PUT AuthorizationType: NONE RequestParameters: {method.request.path.id: true} Integration: Type: AWS_PROXY IntegrationHttpMethod: POST Uri: !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${OrderServiceUpdate.Arn}/invocations PassthroughBehavior: WHEN_NO_MATCH RequestParameters: {integration.request.path.id: 'method.request.path.id'} IntegrationResponses: - StatusCode: 200 ResponseTemplates: {application/json: ''} ResponseParameters: method.response.header.Access-Control-Allow-Origin: "'*'" MethodResponses: - StatusCode: 200 ResponseModels: {application/json: Empty} ResponseParameters: method.response.header.Access-Control-Allow-Origin: false OrderServiceUpdateLambdaPermission: Type: AWS::Lambda::Permission Properties: Principal: apigateway.amazonaws.com Action: lambda:InvokeFunction FunctionName: !GetAtt OrderServiceUpdate.Arn SourceArn: !Sub arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${ApiGatewayLab3Api}/*/PUT/orders/{id} OrderServiceInsertMethod: Type: AWS::ApiGateway::Method Properties: RestApiId: !Ref ApiGatewayLab3Api ResourceId: !Ref OrderServiceOrdersResource HttpMethod: POST AuthorizationType: NONE Integration: Type: AWS_PROXY IntegrationHttpMethod: POST Uri: !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${OrderServiceInsert.Arn}/invocations PassthroughBehavior: WHEN_NO_MATCH IntegrationResponses: - StatusCode: 200 ResponseTemplates: {application/json: ''} ResponseParameters: method.response.header.Access-Control-Allow-Origin: "'*'" MethodResponses: - StatusCode: 200 ResponseModels: {application/json: Empty} ResponseParameters: method.response.header.Access-Control-Allow-Origin: false OrderServiceInsertLambdaPermission: Type: AWS::Lambda::Permission Properties: Principal: apigateway.amazonaws.com Action: lambda:InvokeFunction FunctionName: !GetAtt OrderServiceInsert.Arn SourceArn: !Sub arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${ApiGatewayLab3Api}/*/POST/orders OrderServiceDeleteMethod: Type: AWS::ApiGateway::Method Properties: RestApiId: !Ref ApiGatewayLab3Api ResourceId: !Ref OrderServiceByIdResource HttpMethod: DELETE AuthorizationType: NONE RequestParameters: {method.request.path.id: true} Integration: Type: AWS_PROXY IntegrationHttpMethod: POST Uri: !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${OrderServiceDelete.Arn}/invocations PassthroughBehavior: WHEN_NO_MATCH RequestParameters: {integration.request.path.id: 'method.request.path.id'} IntegrationResponses: - StatusCode: 200 ResponseTemplates: {application/json: ''} ResponseParameters: method.response.header.Access-Control-Allow-Origin: "'*'" MethodResponses: - StatusCode: 200 ResponseModels: {application/json: Empty} ResponseParameters: method.response.header.Access-Control-Allow-Origin: false OrderServiceDeleteLambdaPermission: Type: AWS::Lambda::Permission Properties: Principal: apigateway.amazonaws.com Action: lambda:InvokeFunction FunctionName: !GetAtt OrderServiceDelete.Arn SourceArn: !Sub arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${ApiGatewayLab3Api}/*/DELETE/orders/{id} TenantServiceTenantsResource: Type: AWS::ApiGateway::Resource Properties: RestApiId: !Ref ApiGatewayLab3Api ParentId: !GetAtt ApiGatewayLab3Api.RootResourceId PathPart: tenants TenantServiceByIdResource: Type: AWS::ApiGateway::Resource Properties: RestApiId: !Ref ApiGatewayLab3Api ParentId: !Ref TenantServiceTenantsResource PathPart: '{id}' TenantServicePoolResource: Type: AWS::ApiGateway::Resource Properties: RestApiId: !Ref ApiGatewayLab3Api ParentId: !Ref TenantServiceTenantsResource PathPart: pool TenantServiceNextDatabaseResource: Type: AWS::ApiGateway::Resource Properties: RestApiId: !Ref ApiGatewayLab3Api ParentId: !Ref TenantServicePoolResource PathPart: database TenantServiceUpdateUserPoolResource: Type: AWS::ApiGateway::Resource Properties: RestApiId: !Ref ApiGatewayLab3Api ParentId: !Ref TenantServiceByIdResource PathPart: userpool TenantServiceTenantsResourceCORS: Type: AWS::ApiGateway::Method Properties: RestApiId: !Ref ApiGatewayLab3Api ResourceId: !Ref TenantServiceTenantsResource HttpMethod: OPTIONS AuthorizationType: NONE Integration: Type: MOCK PassthroughBehavior: WHEN_NO_MATCH IntegrationResponses: - StatusCode: 200 ResponseTemplates: {application/json: ''} ResponseParameters: method.response.header.Access-Control-Allow-Headers: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'" method.response.header.Access-Control-Allow-Methods: "'GET,POST,OPTIONS'" method.response.header.Access-Control-Allow-Origin: "'*'" method.response.header.Access-Control-Max-Age: "'3600'" method.response.header.X-Requested-With: "'*'" RequestTemplates: application/json: '{"statusCode": 200}' MethodResponses: - StatusCode: 200 ResponseModels: {application/json: Empty} ResponseParameters: method.response.header.Access-Control-Allow-Headers: false method.response.header.Access-Control-Allow-Methods: false method.response.header.Access-Control-Allow-Origin: false method.response.header.Access-Control-Max-Age: false method.response.header.X-Requested-With: false TenantServiceTenantByIdResourceCORS: Type: AWS::ApiGateway::Method Properties: RestApiId: !Ref ApiGatewayLab3Api ResourceId: !Ref TenantServiceByIdResource HttpMethod: OPTIONS AuthorizationType: NONE Integration: Type: MOCK PassthroughBehavior: WHEN_NO_MATCH IntegrationResponses: - StatusCode: 200 ResponseTemplates: {application/json: ''} ResponseParameters: method.response.header.Access-Control-Allow-Headers: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'" method.response.header.Access-Control-Allow-Methods: "'GET,PUT,DELETE,OPTIONS,POST'" method.response.header.Access-Control-Allow-Origin: "'*'" method.response.header.Access-Control-Max-Age: "'3600'" method.response.header.X-Requested-With: "'*'" RequestTemplates: application/json: '{"statusCode": 200}' MethodResponses: - StatusCode: 200 ResponseModels: {application/json: Empty} ResponseParameters: method.response.header.Access-Control-Allow-Headers: false method.response.header.Access-Control-Allow-Methods: false method.response.header.Access-Control-Allow-Origin: false method.response.header.Access-Control-Max-Age: false method.response.header.X-Requested-With: false TenantServiceGetAllMethod: Type: AWS::ApiGateway::Method Properties: RestApiId: !Ref ApiGatewayLab3Api ResourceId: !Ref TenantServiceTenantsResource HttpMethod: GET AuthorizationType: NONE Integration: Type: AWS_PROXY IntegrationHttpMethod: POST Uri: !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${TenantServiceGetAllArn}/invocations PassthroughBehavior: WHEN_NO_MATCH IntegrationResponses: - StatusCode: 200 ResponseTemplates: {application/json: ''} ResponseParameters: method.response.header.Access-Control-Allow-Origin: "'*'" MethodResponses: - StatusCode: 200 ResponseModels: {application/json: Empty} ResponseParameters: method.response.header.Access-Control-Allow-Origin: false TenantServiceGetAllLambdaPermission: Type: AWS::Lambda::Permission Properties: Principal: apigateway.amazonaws.com Action: lambda:InvokeFunction FunctionName: !Ref TenantServiceGetAllArn SourceArn: !Sub arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${ApiGatewayLab3Api}/*/GET/tenants TenantServiceGetByIdMethod: Type: AWS::ApiGateway::Method Properties: RestApiId: !Ref ApiGatewayLab3Api ResourceId: !Ref TenantServiceByIdResource HttpMethod: GET AuthorizationType: NONE RequestParameters: {method.request.path.id: true} Integration: Type: AWS_PROXY IntegrationHttpMethod: POST Uri: !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${TenantServiceGetByIdArn}/invocations PassthroughBehavior: WHEN_NO_MATCH RequestParameters: {integration.request.path.id: 'method.request.path.id'} IntegrationResponses: - StatusCode: 200 ResponseTemplates: {application/json: ''} ResponseParameters: method.response.header.Access-Control-Allow-Origin: "'*'" MethodResponses: - StatusCode: 200 ResponseModels: {application/json: Empty} ResponseParameters: method.response.header.Access-Control-Allow-Origin: false TenantServiceGetByIdLambdaPermission: Type: AWS::Lambda::Permission Properties: Principal: apigateway.amazonaws.com Action: lambda:InvokeFunction FunctionName: !Ref TenantServiceGetByIdArn SourceArn: !Sub arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${ApiGatewayLab3Api}/*/GET/tenants/{id} TenantServiceUpdateMethod: Type: AWS::ApiGateway::Method Properties: RestApiId: !Ref ApiGatewayLab3Api ResourceId: !Ref TenantServiceByIdResource HttpMethod: PUT AuthorizationType: NONE RequestParameters: {method.request.path.id: true} Integration: Type: AWS_PROXY IntegrationHttpMethod: POST Uri: !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${TenantServiceUpdateArn}/invocations PassthroughBehavior: WHEN_NO_MATCH RequestParameters: {integration.request.path.id: 'method.request.path.id'} IntegrationResponses: - StatusCode: 200 ResponseTemplates: {application/json: ''} ResponseParameters: method.response.header.Access-Control-Allow-Origin: "'*'" MethodResponses: - StatusCode: 200 ResponseModels: {application/json: Empty} ResponseParameters: method.response.header.Access-Control-Allow-Origin: false TenantServiceUpdateLambdaPermission: Type: AWS::Lambda::Permission Properties: Principal: apigateway.amazonaws.com Action: lambda:InvokeFunction FunctionName: !Ref TenantServiceUpdateArn SourceArn: !Sub arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${ApiGatewayLab3Api}/*/PUT/tenants/{id} TenantServiceInsertMethod: Type: AWS::ApiGateway::Method Properties: RestApiId: !Ref ApiGatewayLab3Api ResourceId: !Ref TenantServiceTenantsResource HttpMethod: POST AuthorizationType: NONE Integration: Type: AWS_PROXY IntegrationHttpMethod: POST Uri: !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${TenantServiceInsertArn}/invocations PassthroughBehavior: WHEN_NO_MATCH IntegrationResponses: - StatusCode: 200 ResponseTemplates: {application/json: ''} ResponseParameters: method.response.header.Access-Control-Allow-Origin: "'*'" MethodResponses: - StatusCode: 200 ResponseModels: {application/json: Empty} ResponseParameters: method.response.header.Access-Control-Allow-Origin: false TenantServiceInsertLambdaPermission: Type: AWS::Lambda::Permission Properties: Principal: apigateway.amazonaws.com Action: lambda:InvokeFunction FunctionName: !Ref TenantServiceInsertArn SourceArn: !Sub arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${ApiGatewayLab3Api}/*/POST/tenants TenantServiceDeleteMethod: Type: AWS::ApiGateway::Method Properties: RestApiId: !Ref ApiGatewayLab3Api ResourceId: !Ref TenantServiceByIdResource HttpMethod: DELETE AuthorizationType: NONE RequestParameters: {method.request.path.id: true} Integration: Type: AWS_PROXY IntegrationHttpMethod: POST Uri: !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${TenantServiceDeleteArn}/invocations PassthroughBehavior: WHEN_NO_MATCH RequestParameters: {integration.request.path.id: 'method.request.path.id'} IntegrationResponses: - StatusCode: 200 ResponseTemplates: {application/json: ''} ResponseParameters: method.response.header.Access-Control-Allow-Origin: "'*'" MethodResponses: - StatusCode: 200 ResponseModels: {application/json: Empty} ResponseParameters: method.response.header.Access-Control-Allow-Origin: false TenantServiceDeleteLambdaPermission: Type: AWS::Lambda::Permission Properties: Principal: apigateway.amazonaws.com Action: lambda:InvokeFunction FunctionName: !Ref TenantServiceDeleteArn SourceArn: !Sub arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${ApiGatewayLab3Api}/*/DELETE/tenants/{id} TenantServiceNextDatabaseMethod: Type: AWS::ApiGateway::Method Properties: RestApiId: !Ref ApiGatewayLab3Api ResourceId: !Ref TenantServiceNextDatabaseResource HttpMethod: GET AuthorizationType: NONE Integration: Type: AWS_PROXY IntegrationHttpMethod: POST Uri: !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${TenantServiceNextDbArn}/invocations PassthroughBehavior: WHEN_NO_MATCH IntegrationResponses: - StatusCode: 200 ResponseTemplates: {application/json: ''} ResponseParameters: method.response.header.Access-Control-Allow-Origin: "'*'" MethodResponses: - StatusCode: 200 ResponseModels: {application/json: Empty} ResponseParameters: method.response.header.Access-Control-Allow-Origin: false TenantServiceNextDatabaseLambdaPermission: Type: AWS::Lambda::Permission Properties: Principal: apigateway.amazonaws.com Action: lambda:InvokeFunction FunctionName: !Ref TenantServiceNextDbArn SourceArn: !Sub arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${ApiGatewayLab3Api}/*/GET/tenants/pool/database TenantServiceUpdateUserPoolMethod: Type: AWS::ApiGateway::Method Properties: RestApiId: !Ref ApiGatewayLab3Api ResourceId: !Ref TenantServiceUpdateUserPoolResource HttpMethod: PUT AuthorizationType: NONE RequestParameters: {method.request.path.id: true} Integration: Type: AWS_PROXY IntegrationHttpMethod: POST Uri: !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${TenantServiceUpdateUserPoolArn}/invocations PassthroughBehavior: WHEN_NO_MATCH RequestParameters: {integration.request.path.id: 'method.request.path.id'} IntegrationResponses: - StatusCode: 200 ResponseTemplates: {application/json: ''} ResponseParameters: method.response.header.Access-Control-Allow-Origin: "'*'" MethodResponses: - StatusCode: 200 ResponseModels: {application/json: Empty} ResponseParameters: method.response.header.Access-Control-Allow-Origin: false TenantServiceUpdateUserPoolLambdaPermission: Type: AWS::Lambda::Permission Properties: Principal: apigateway.amazonaws.com Action: lambda:InvokeFunction FunctionName: !Ref TenantServiceUpdateUserPoolArn SourceArn: !Sub arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${ApiGatewayLab3Api}/*/PUT/tenants/{id}/userpool RegistrationServiceRegisterResource: Type: AWS::ApiGateway::Resource Properties: RestApiId: !Ref ApiGatewayLab3Api ParentId: !GetAtt ApiGatewayLab3Api.RootResourceId PathPart: registration RegistrationServiceRegisterResourceCORS: Type: AWS::ApiGateway::Method Properties: RestApiId: !Ref ApiGatewayLab3Api ResourceId: !Ref RegistrationServiceRegisterResource HttpMethod: OPTIONS AuthorizationType: NONE Integration: Type: MOCK PassthroughBehavior: WHEN_NO_MATCH IntegrationResponses: - StatusCode: 200 ResponseTemplates: {application/json: ''} ResponseParameters: method.response.header.Access-Control-Allow-Headers: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'" method.response.header.Access-Control-Allow-Methods: "'GET,POST,OPTIONS'" method.response.header.Access-Control-Allow-Origin: "'*'" method.response.header.Access-Control-Max-Age: "'3600'" method.response.header.X-Requested-With: "'*'" RequestTemplates: application/json: '{"statusCode": 200}' MethodResponses: - StatusCode: 200 ResponseModels: {application/json: Empty} ResponseParameters: method.response.header.Access-Control-Allow-Headers: false method.response.header.Access-Control-Allow-Methods: false method.response.header.Access-Control-Allow-Origin: false method.response.header.Access-Control-Max-Age: false method.response.header.X-Requested-With: false RegistrationServiceRegisterMethod: Type: AWS::ApiGateway::Method Properties: RestApiId: !Ref ApiGatewayLab3Api ResourceId: !Ref RegistrationServiceRegisterResource HttpMethod: POST AuthorizationType: NONE Integration: Type: AWS_PROXY IntegrationHttpMethod: POST Uri: !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${RegistrationServiceRegisterArn}/invocations PassthroughBehavior: WHEN_NO_MATCH IntegrationResponses: - StatusCode: 200 ResponseTemplates: {application/json: ''} ResponseParameters: method.response.header.Access-Control-Allow-Origin: "'*'" MethodResponses: - StatusCode: 200 ResponseModels: {application/json: Empty} ResponseParameters: method.response.header.Access-Control-Allow-Origin: false RegistrationServiceRegisterLambdaPermission: Type: AWS::Lambda::Permission Properties: Principal: apigateway.amazonaws.com Action: lambda:InvokeFunction FunctionName: !Ref RegistrationServiceRegisterArn SourceArn: !Sub arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${ApiGatewayLab3Api}/*/POST/registration AuthServiceSignInResource: Type: AWS::ApiGateway::Resource Properties: RestApiId: !Ref ApiGatewayLab3Api ParentId: !GetAtt ApiGatewayLab3Api.RootResourceId PathPart: auth AuthServiceSignInResourceCORS: Type: AWS::ApiGateway::Method Properties: RestApiId: !Ref ApiGatewayLab3Api ResourceId: !Ref AuthServiceSignInResource HttpMethod: OPTIONS AuthorizationType: NONE Integration: Type: MOCK PassthroughBehavior: WHEN_NO_MATCH IntegrationResponses: - StatusCode: 200 ResponseTemplates: {application/json: ''} ResponseParameters: method.response.header.Access-Control-Allow-Headers: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'" method.response.header.Access-Control-Allow-Methods: "'GET,POST,OPTIONS'" method.response.header.Access-Control-Allow-Origin: "'*'" method.response.header.Access-Control-Max-Age: "'3600'" method.response.header.X-Requested-With: "'*'" RequestTemplates: application/json: '{"statusCode": 200}' MethodResponses: - StatusCode: 200 ResponseModels: {application/json: Empty} ResponseParameters: method.response.header.Access-Control-Allow-Headers: false method.response.header.Access-Control-Allow-Methods: false method.response.header.Access-Control-Allow-Origin: false method.response.header.Access-Control-Max-Age: false method.response.header.X-Requested-With: false AuthServiceSignInMethod: Type: AWS::ApiGateway::Method Properties: RestApiId: !Ref ApiGatewayLab3Api ResourceId: !Ref AuthServiceSignInResource HttpMethod: POST AuthorizationType: NONE Integration: Type: AWS_PROXY IntegrationHttpMethod: POST Uri: !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${AuthServiceSignInArn}/invocations PassthroughBehavior: WHEN_NO_MATCH IntegrationResponses: - StatusCode: 200 ResponseTemplates: {application/json: ''} ResponseParameters: method.response.header.Access-Control-Allow-Origin: "'*'" MethodResponses: - StatusCode: 200 ResponseModels: {application/json: Empty} ResponseParameters: method.response.header.Access-Control-Allow-Origin: false AuthServiceSignInLambdaPermission: Type: AWS::Lambda::Permission Properties: Principal: apigateway.amazonaws.com Action: lambda:InvokeFunction FunctionName: !Ref AuthServiceSignInArn SourceArn: !Sub arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${ApiGatewayLab3Api}/*/POST/auth ApiGatewayLab3ApiDeployment: Type: AWS::ApiGateway::Deployment DependsOn: - ProductServiceProductsResourceCORS - ProductServiceProductByIdResourceCORS - ProductServiceGetAllMethod - ProductServiceGetByIdMethod - ProductServiceUpdateMethod - ProductServiceInsertMethod - ProductServiceDeleteMethod - ProductServiceCategoriesResourceCORS - ProductServiceCategoryByIdResourceCORS - ProductServiceGetAllCategoriesMethod - ProductServiceGetCategoryByIdMethod - ProductServiceUpdateCategoryMethod - ProductServiceInsertCategoryMethod - ProductServiceDeleteCategoryMethod - OrderServiceOrderByIdResourceCORS - OrderServiceOrdersResourceCORS - OrderServiceGetAllMethod - OrderServiceGetByIdMethod - OrderServiceUpdateMethod - OrderServiceInsertMethod - OrderServiceDeleteMethod - TenantServiceTenantsResourceCORS - TenantServiceTenantByIdResourceCORS - TenantServiceGetAllMethod - TenantServiceGetByIdMethod - TenantServiceUpdateMethod - TenantServiceInsertMethod - TenantServiceDeleteMethod - TenantServiceNextDatabaseMethod - TenantServiceUpdateUserPoolMethod - RegistrationServiceRegisterResourceCORS - RegistrationServiceRegisterMethod - AuthServiceSignInResourceCORS - AuthServiceSignInMethod Properties: RestApiId: !Ref ApiGatewayLab3Api ApiGatewayLab3ApiStage: Type: AWS::ApiGateway::Stage Properties: RestApiId: !Ref ApiGatewayLab3Api StageName: v1 DeploymentId: !Ref ApiGatewayLab3ApiDeployment CloudWatchEventRuleForLambdaWarmer: Type: AWS::Events::Rule DependsOn: - ApiGatewayLab3Api - ApiGatewayLab3ApiStage Properties: Description: Scheduled event to keep Lambda functions warm Name: !Sub saas-factory-srvls-wrkshp-event-rule-lab3-${AWS::Region} ScheduleExpression: 'rate(1 minute)' State: ENABLED Targets: - Arn: !Ref LambdaWarmerArn Id: LambdaWarmerTarget Input: !Join - '' - - '{"Endpoint": "' - !Sub 'https://${ApiGatewayLab3Api}.execute-api.${AWS::Region}.amazonaws.com/${ApiGatewayLab3ApiStage}' - '","Warmup": ["' - !Ref TenantServiceGetAllArn - '", "' - !Ref TenantServiceGetByIdArn - '", "' - !Ref TenantServiceInsertArn - '", "' - !Ref TenantServiceUpdateArn - '", "' - !Ref TenantServiceDeleteArn - '", "' - !Ref TenantServiceNextDbArn - '", "' - !Ref TenantServiceUpdateUserPoolArn - '", "' - !Ref RegistrationServiceRegisterArn - '", "' - !Ref AuthServiceSignInArn - '", "' - !Ref LambdaCustomAuthorizerArn - '"]}' Outputs: ApiGatewayEndpointLab3: Description: API Gateway Invoke URL Value: !Sub 'https://${ApiGatewayLab3Api}.execute-api.${AWS::Region}.amazonaws.com/${ApiGatewayLab3ApiStage}' OrderServiceGetAllArn: Description: OrderService getByAll function ARN Value: !GetAtt OrderServiceGetAll.Arn OrderServiceGetByIdArn: Description: OrderService getById function ARN Value: !GetAtt OrderServiceGetById.Arn OrderServiceUpdateArn: Description: OrderService update function ARN Value: !GetAtt OrderServiceUpdate.Arn OrderServiceInsertArn: Description: OrderService insert function ARN Value: !GetAtt OrderServiceInsert.Arn OrderServiceDeleteArn: Description: OrderService delete function ARN Value: !GetAtt OrderServiceDelete.Arn ...