forked from makspiechota/aws-codepipeline-training-pl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstack.yaml
89 lines (81 loc) · 2.2 KB
/
stack.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
AWSTemplateFormatVersion: 2010-09-09
Resources:
ApiProxyFunction:
Type: 'AWS::Lambda::Function'
Properties:
Code: ./
FunctionName: 'AWSTrainingLambdaFunction'
MemorySize: 256
Tags:
- Value: SAM
Key: 'lambda:createdBy'
Handler: ./src/handler.handler
Role: !GetAtt
- ProxyApiRole
- Arn
Runtime: nodejs18.x
Timeout: 30
ProxyApiRole:
Type: 'AWS::IAM::Role'
Properties:
ManagedPolicyArns:
- 'arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole'
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Action:
- 'sts:AssumeRole'
Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
ApiProxyFunctionPermission:
Type: 'AWS::Lambda::Permission'
Properties:
Action: 'lambda:InvokeFunction'
Principal: apigateway.amazonaws.com
FunctionName: !Ref ApiProxyFunction
ProxyApi:
Type: AWS::ApiGateway::RestApi
Properties:
Description: Proxy API Gateway
EndpointConfiguration:
Types:
- REGIONAL
Name: 'AWSTrainingProxyApi'
ProxyResource:
Type: 'AWS::ApiGateway::Resource'
Properties:
RestApiId: !Ref ProxyApi
ParentId: !GetAtt
- ProxyApi
- RootResourceId
PathPart: '{proxy+}'
ProxyResourceANY:
Type: 'AWS::ApiGateway::Method'
Properties:
RestApiId: !Ref ProxyApi
ResourceId: !Ref ProxyResource
HttpMethod: ANY
AuthorizationType: NONE
Integration:
Type: AWS_PROXY
IntegrationHttpMethod: POST
Uri: !Sub >-
arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ApiProxyFunction.Arn}/invocations
ApiProxyDeployment:
Type: AWS::ApiGateway::Deployment
DependsOn:
- ProxyApiRootMethod
ApiProxyDeployment:
Type: AWS::ApiGateway::Deployment
DependsOn:
- ProxyResourceANY
Properties:
RestApiId: !Ref ProxyApi
StageName: 'dev'
Outputs:
ApiUrl:
Description: URL of the API Gateway endpoint
Value: !Sub
https://${ProxyApi}.execute-api.${AWS::Region}.amazonaws.com/dev/