-
Notifications
You must be signed in to change notification settings - Fork 112
Expand file tree
/
Copy pathiam-role-for-temporal-lambda-invoke-test.yaml
More file actions
97 lines (88 loc) · 3.14 KB
/
Copy pathiam-role-for-temporal-lambda-invoke-test.yaml
File metadata and controls
97 lines (88 loc) · 3.14 KB
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
89
90
91
92
93
94
95
96
97
# CloudFormation template for creating an IAM role that Temporal Cloud can assume to invoke Lambda functions.
AWSTemplateFormatVersion: "2010-09-09"
Description: Creates an IAM role that Temporal Cloud can assume to invoke multiple Lambda functions for Serverless Workers.
Parameters:
AssumeRoleExternalId:
Type: String
Description: The External ID provided by Temporal Cloud
AllowedPattern: "[a-zA-Z0-9_+=,.@-]*"
MinLength: 5
MaxLength: 45
LambdaFunctionARNs:
Type: CommaDelimitedList
Description: >-
Comma-separated list of Lambda function ARNs to invoke (e.g.,
arn:aws:lambda:us-west-2:123456789012:function:worker-1,arn:aws:lambda:us-west-2:123456789012:function:worker-2)
RoleName:
Type: String
Default: "Temporal-Cloud-Serverless-Worker"
Metadata:
AWS::CloudFormation::Interface:
ParameterGroups:
- Label:
default: "Temporal Cloud Configuration"
Parameters:
- AssumeRoleExternalId
- Label:
default: "Lambda Configuration"
Parameters:
- LambdaFunctionARNs
- RoleName
ParameterLabels:
AssumeRoleExternalId:
default: "External ID (provided by Temporal Cloud)"
LambdaFunctionARNs:
default: "Lambda Function ARNs (comma-separated list)"
RoleName:
default: "IAM Role Name"
Resources:
TemporalCloudServerlessWorker:
Type: AWS::IAM::Role
Properties:
RoleName: !Sub "${RoleName}-${AWS::StackName}"
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
AWS:
[
arn:aws:iam::902542641901:role/wci-lambda-invoke,
arn:aws:iam::160190466495:role/wci-lambda-invoke,
arn:aws:iam::819232936619:role/wci-lambda-invoke,
arn:aws:iam::829909441867:role/wci-lambda-invoke,
arn:aws:iam::354116250941:role/wci-lambda-invoke,
]
Action: sts:AssumeRole
Condition:
StringEquals:
"sts:ExternalId": [!Ref AssumeRoleExternalId]
Description: "The role Temporal Cloud uses to invoke Lambda functions for Serverless Workers"
MaxSessionDuration: 3600 # 1 hour
TemporalCloudLambdaInvokePermissions:
Type: AWS::IAM::Policy
DependsOn: TemporalCloudServerlessWorker
Properties:
PolicyName: "Temporal-Cloud-Lambda-Invoke-Permissions"
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- lambda:InvokeFunction
- lambda:GetFunction
Resource: !Ref LambdaFunctionARNs
Roles:
- !Sub "${RoleName}-${AWS::StackName}"
Outputs:
RoleARN:
Description: The ARN of the IAM role created for Temporal Cloud
Value: !GetAtt TemporalCloudServerlessWorker.Arn
Export:
Name: !Sub "${AWS::StackName}-RoleARN"
RoleName:
Description: The name of the IAM role
Value: !Ref RoleName
LambdaFunctionARNs:
Description: The Lambda function ARNs that can be invoked
Value: !Join [", ", !Ref LambdaFunctionARNs]