-
Notifications
You must be signed in to change notification settings - Fork 195
/
Copy pathaws-cf-stack-for-layer-publish.yml
53 lines (50 loc) · 1.72 KB
/
aws-cf-stack-for-layer-publish.yml
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
Parameters:
GitHubOrgName:
Description: Name of the GitHub organization/user
Type: String
RepositoryName:
Description: Name of the GitHub repository
Type: String
Default: "opentelemetry-lambda"
Resources:
Role:
Type: AWS::IAM::Role
Properties:
RoleName: "github-otel-lambda-layer-publish-role"
AssumeRolePolicyDocument:
Statement:
- Effect: Allow
Action: sts:AssumeRoleWithWebIdentity
Principal:
Federated: !Ref GithubOIDC
Condition:
StringEquals:
token.actions.githubusercontent.com:aud: "sts.amazonaws.com"
StringLike:
token.actions.githubusercontent.com:sub: !Sub "repo:${GitHubOrgName}/${RepositoryName}:*"
Policies:
- PolicyName: "github-otel-lambda-layer-publish-policy"
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- "lambda:GetLayer*"
- "lambda:ListLayer*"
- "lambda:AddLayer*"
- "lambda:PublishLayer*"
Resource:
- !Sub "arn:aws:lambda:*:${AWS::AccountId}:layer:opentelemetry-*"
- !Sub "arn:aws:lambda:*:${AWS::AccountId}:layer:opentelemetry-*:*"
GithubOIDC:
Type: AWS::IAM::OIDCProvider
Properties:
Url: "https://token.actions.githubusercontent.com"
ClientIdList:
- "sts.amazonaws.com"
ThumbprintList:
- "ffffffffffffffffffffffffffffffffffffffff"
Outputs:
RoleARN:
Description: "ARN of the AWS IAM role to be assumed by Github for the OpenTelemetry Layer publishing"
Value: !GetAtt Role.Arn