michalvankodev-site/amplify/backend/api/auth/auth-cloudformation-template.json
2020-11-20 16:27:23 +01:00

404 lines
13 KiB
JSON

{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "API Gateway resource stack creation using Amplify CLI",
"Parameters": {
"authRoleName": {
"Type": "String"
},
"unauthRoleName": {
"Type": "String"
},
"env": {
"Type": "String"
},
"functionauthFunctionName": {
"Type": "String",
"Default": "functionauthFunctionName"
},
"functionauthFunctionArn": {
"Type": "String",
"Default": "functionauthFunctionArn"
}
},
"Conditions": {
"ShouldNotCreateEnvResources": {
"Fn::Equals": [
{
"Ref": "env"
},
"NONE"
]
}
},
"Resources": {
"auth": {
"Type": "AWS::ApiGateway::RestApi",
"Properties": {
"Description": "",
"Name": "auth",
"Body": {
"swagger": "2.0",
"info": {
"version": "2018-05-24T17:52:00Z",
"title": "auth"
},
"host": {
"Fn::Join": [
"",
[
"apigateway.",
{
"Ref": "AWS::Region"
},
".amazonaws.com"
]
]
},
"basePath": {
"Fn::If": [
"ShouldNotCreateEnvResources",
"/Prod",
{
"Fn::Join": [
"",
[
"/",
{
"Ref": "env"
}
]
]
}
]
},
"schemes": [
"https"
],
"paths": {
"/auth": {
"options": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"responses": {
"200": {
"description": "200 response",
"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,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token,X-Amz-User-Agent'",
"method.response.header.Access-Control-Allow-Origin": "'*'"
}
}
},
"requestTemplates": {
"application/json": "{\"statusCode\": 200}"
},
"passthroughBehavior": "when_no_match",
"type": "mock"
}
},
"x-amazon-apigateway-any-method": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"parameters": [
{
"in": "body",
"name": "RequestSchema",
"required": false,
"schema": {
"$ref": "#/definitions/RequestSchema"
}
}
],
"responses": {
"200": {
"description": "200 response",
"schema": {
"$ref": "#/definitions/ResponseSchema"
}
}
},
"x-amazon-apigateway-integration": {
"responses": {
"default": {
"statusCode": "200"
}
},
"uri": {
"Fn::Join": [
"",
[
"arn:aws:apigateway:",
{
"Ref": "AWS::Region"
},
":lambda:path/2015-03-31/functions/",
{
"Ref": "functionauthFunctionArn"
},
"/invocations"
]
]
},
"passthroughBehavior": "when_no_match",
"httpMethod": "POST",
"type": "aws_proxy"
}
}
},
"/auth/{proxy+}": {
"options": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"responses": {
"200": {
"description": "200 response",
"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,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token,X-Amz-User-Agent'",
"method.response.header.Access-Control-Allow-Origin": "'*'"
}
}
},
"requestTemplates": {
"application/json": "{\"statusCode\": 200}"
},
"passthroughBehavior": "when_no_match",
"type": "mock"
}
},
"x-amazon-apigateway-any-method": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"parameters": [
{
"in": "body",
"name": "RequestSchema",
"required": false,
"schema": {
"$ref": "#/definitions/RequestSchema"
}
}
],
"responses": {
"200": {
"description": "200 response",
"schema": {
"$ref": "#/definitions/ResponseSchema"
}
}
},
"x-amazon-apigateway-integration": {
"responses": {
"default": {
"statusCode": "200"
}
},
"uri": {
"Fn::Join": [
"",
[
"arn:aws:apigateway:",
{
"Ref": "AWS::Region"
},
":lambda:path/2015-03-31/functions/",
{
"Ref": "functionauthFunctionArn"
},
"/invocations"
]
]
},
"passthroughBehavior": "when_no_match",
"httpMethod": "POST",
"type": "aws_proxy"
}
}
}
},
"securityDefinitions": {
"sigv4": {
"type": "apiKey",
"name": "Authorization",
"in": "header",
"x-amazon-apigateway-authtype": "awsSigv4"
}
},
"definitions": {
"RequestSchema": {
"type": "object",
"required": [
"request"
],
"properties": {
"request": {
"type": "string"
}
},
"title": "Request Schema"
},
"ResponseSchema": {
"type": "object",
"required": [
"response"
],
"properties": {
"response": {
"type": "string"
}
},
"title": "Response Schema"
}
}
},
"FailOnWarnings": true
}
},
"functionauthFunctionPermissionauth": {
"Type": "AWS::Lambda::Permission",
"Properties": {
"FunctionName":
{
"Ref": "functionauthFunctionName"
},
"Action": "lambda:InvokeFunction",
"Principal": "apigateway.amazonaws.com",
"SourceArn": {
"Fn::Join": [
"",
[
"arn:aws:execute-api:",
{
"Ref": "AWS::Region"
},
":",
{
"Ref": "AWS::AccountId"
},
":",
{
"Ref": "auth"
},
"/*/*/*"
]
]
}
}
},
"DeploymentAPIGWauth": {
"Type": "AWS::ApiGateway::Deployment",
"Properties": {
"Description": "The Development stage deployment of your API.",
"StageName": {
"Fn::If": [
"ShouldNotCreateEnvResources",
"Prod",
{
"Ref": "env"
}
]
},
"RestApiId": {
"Ref": "auth"
}
}
}
},
"Outputs": {
"RootUrl": {
"Description": "Root URL of the API gateway",
"Value": {"Fn::Join": ["", ["https://", {"Ref": "auth"}, ".execute-api.", {"Ref": "AWS::Region"}, ".amazonaws.com/", {"Fn::If": ["ShouldNotCreateEnvResources","Prod", {"Ref": "env"} ]}]]}
},
"ApiName": {
"Description": "API Friendly name",
"Value": "auth"
},
"ApiId": {
"Description": "API ID (prefix of API URL)",
"Value": {"Ref": "auth"}
}
}
}