-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcfn-workshop-setup.yaml
More file actions
345 lines (321 loc) · 12.5 KB
/
cfn-workshop-setup.yaml
File metadata and controls
345 lines (321 loc) · 12.5 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
AWSTemplateFormatVersion: '2010-09-09'
Description: >
Agentic Process Transformation Workshop — provisions S3 bucket, DynamoDB tables,
SageMaker execution role with least-privilege permissions, and uploads sample data.
Parameters:
S3BucketName:
Type: String
Default: ''
Description: >
(Optional) Custom S3 bucket name. Leave blank to auto-generate a unique name
using your account ID and region.
Conditions:
UseAutoGeneratedBucketName: !Equals [!Ref S3BucketName, '']
Resources:
# ── S3 Bucket for claim documents ──────────────────────────────────────────
WorkshopS3Bucket:
Type: AWS::S3::Bucket
DeletionPolicy: Delete
Properties:
BucketName: !If
- UseAutoGeneratedBucketName
- !Sub 'agentic-workshop-${AWS::AccountId}-${AWS::Region}'
- !Ref S3BucketName
PublicAccessBlockConfiguration:
BlockPublicAcls: true
BlockPublicPolicy: true
IgnorePublicAcls: true
RestrictPublicBuckets: true
BucketEncryption:
ServerSideEncryptionConfiguration:
- ServerSideEncryptionByDefault:
SSEAlgorithm: AES256
Tags:
- Key: Project
Value: agentic-process-transformation
WorkshopS3BucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref WorkshopS3Bucket
PolicyDocument:
Version: '2012-10-17'
Statement:
- Sid: DenyNonSSLRequests
Effect: Deny
Principal: '*'
Action: 's3:*'
Resource:
- !GetAtt WorkshopS3Bucket.Arn
- !Sub '${WorkshopS3Bucket.Arn}/*'
Condition:
Bool:
aws:SecureTransport: 'false'
# ── DynamoDB Tables ────────────────────────────────────────────────────────
ClaimsMetadataTable:
Type: AWS::DynamoDB::Table
DeletionPolicy: Delete
Properties:
TableName: claims-metadata
BillingMode: PAY_PER_REQUEST
AttributeDefinitions:
- AttributeName: claim_id
AttributeType: S
KeySchema:
- AttributeName: claim_id
KeyType: HASH
SSESpecification:
SSEEnabled: true
Tags:
- Key: Project
Value: agentic-process-transformation
DemoClaimsMetadataTable:
Type: AWS::DynamoDB::Table
DeletionPolicy: Delete
Properties:
TableName: demo-claims-metadata
BillingMode: PAY_PER_REQUEST
AttributeDefinitions:
- AttributeName: claim_id
AttributeType: S
KeySchema:
- AttributeName: claim_id
KeyType: HASH
SSESpecification:
SSEEnabled: true
Tags:
- Key: Project
Value: agentic-process-transformation
# ── IAM Role for Step Functions (HITL) ─────────────────────────────────────
StepFunctionsHITLRole:
Type: AWS::IAM::Role
Properties:
RoleName: claims-hitl-sfn-role
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service: states.amazonaws.com
Action: sts:AssumeRole
Policies:
- PolicyName: claims-hitl-dynamodb-access
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:GetItem
Resource:
- !GetAtt ClaimsMetadataTable.Arn
- !GetAtt DemoClaimsMetadataTable.Arn
Tags:
- Key: Project
Value: agentic-process-transformation
DemoStepFunctionsHITLRole:
Type: AWS::IAM::Role
Properties:
RoleName: demo-claims-hitl-sfn-role
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service: states.amazonaws.com
Action: sts:AssumeRole
Policies:
- PolicyName: demo-hitl-dynamodb
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:GetItem
Resource:
- !GetAtt DemoClaimsMetadataTable.Arn
Tags:
- Key: Project
Value: agentic-process-transformation
# ── SageMaker Execution Role ───────────────────────────────────────────────
SageMakerExecutionRole:
Type: AWS::IAM::Role
Properties:
RoleName: !Sub 'agentic-workshop-sagemaker-role-${AWS::Region}'
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service: sagemaker.amazonaws.com
Action: sts:AssumeRole
ManagedPolicyArns:
- arn:aws:iam::aws:policy/AmazonSageMakerFullAccess
Policies:
# ── Bedrock: model inference ──
- PolicyName: bedrock-inference
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- bedrock:InvokeModel
- bedrock:InvokeModelWithResponseStream
Resource:
- !Sub 'arn:aws:bedrock:${AWS::Region}::foundation-model/amazon.nova-2-lite-v1:0'
- !Sub 'arn:aws:bedrock:${AWS::Region}::foundation-model/amazon.nova-2-multimodal-embeddings-v1:0'
- !Sub 'arn:aws:bedrock:${AWS::Region}::foundation-model/anthropic.claude-sonnet-4-6'
- !Sub 'arn:aws:bedrock:${AWS::Region}:${AWS::AccountId}:inference-profile/us.amazon.nova-2-lite-v1:0'
- !Sub 'arn:aws:bedrock:${AWS::Region}:${AWS::AccountId}:inference-profile/us.anthropic.claude-sonnet-4-6'
- 'arn:aws:bedrock:*::foundation-model/amazon.nova-2-lite-v1:0'
- 'arn:aws:bedrock:*::foundation-model/amazon.nova-2-multimodal-embeddings-v1:0'
- 'arn:aws:bedrock:*::foundation-model/anthropic.claude-sonnet-4-6'
# ── Bedrock AgentCore: memory management ──
- PolicyName: bedrock-agentcore-memory
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- bedrock-agentcore:*
Resource: '*'
# ── S3: read/write claim documents ──
- PolicyName: s3-claim-documents
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- s3:ListBucket
- s3:ListAllMyBuckets
Resource: '*'
- Effect: Allow
Action:
- s3:GetObject
- s3:PutObject
Resource:
- !Sub '${WorkshopS3Bucket.Arn}/*'
# ── DynamoDB: claim metadata tables ──
- PolicyName: dynamodb-claims-tables
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- dynamodb:CreateTable
- dynamodb:DescribeTable
- dynamodb:DeleteTable
- dynamodb:PutItem
- dynamodb:GetItem
- dynamodb:UpdateItem
- dynamodb:Scan
Resource:
- !GetAtt ClaimsMetadataTable.Arn
- !GetAtt DemoClaimsMetadataTable.Arn
# ── Step Functions: HITL orchestration ──
- PolicyName: step-functions-hitl
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- states:CreateStateMachine
- states:DescribeStateMachine
- states:DeleteStateMachine
- states:StartExecution
- states:StopExecution
- states:SendTaskSuccess
- states:CreateActivity
- states:GetActivityTask
- states:ListExecutions
- states:DescribeExecution
- states:DeleteActivity
Resource:
- !Sub 'arn:aws:states:${AWS::Region}:${AWS::AccountId}:stateMachine:claims-hitl-*'
- !Sub 'arn:aws:states:${AWS::Region}:${AWS::AccountId}:stateMachine:demo-claims-hitl-*'
- !Sub 'arn:aws:states:${AWS::Region}:${AWS::AccountId}:activity:demo-claims-*'
- !Sub 'arn:aws:states:${AWS::Region}:${AWS::AccountId}:activity:claims-*'
- !Sub 'arn:aws:states:${AWS::Region}:${AWS::AccountId}:execution:*:*'
# ── IAM: manage Step Functions execution roles ──
- PolicyName: iam-sfn-role-management
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- iam:CreateRole
- iam:GetRole
- iam:PutRolePolicy
- iam:DeleteRolePolicy
- iam:DeleteRole
Resource:
- !Sub 'arn:aws:iam::${AWS::AccountId}:role/claims-hitl-sfn-role'
- !Sub 'arn:aws:iam::${AWS::AccountId}:role/demo-claims-hitl-sfn-role'
- Effect: Allow
Action:
- iam:PassRole
Resource:
- !Sub 'arn:aws:iam::${AWS::AccountId}:role/claims-hitl-sfn-role'
- !Sub 'arn:aws:iam::${AWS::AccountId}:role/demo-claims-hitl-sfn-role'
Condition:
StringEquals:
iam:PassedToService: states.amazonaws.com
# ── STS: get caller identity ──
- PolicyName: sts-get-caller-identity
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- sts:GetCallerIdentity
Resource: '*'
# ── CloudFormation: read stack outputs ──
- PolicyName: cloudformation-read
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- cloudformation:DescribeStacks
- cloudformation:ListStacks
Resource: '*'
# ── Marketplace: model subscriptions ──
- PolicyName: marketplace-model-access
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- aws-marketplace:ViewSubscriptions
- aws-marketplace:Subscribe
- aws-marketplace:Unsubscribe
Resource: '*'
Tags:
- Key: Project
Value: agentic-process-transformation
# ── Outputs ──────────────────────────────────────────────────────────────────
Outputs:
S3BucketName:
Description: S3 bucket for workshop claim documents
Value: !Ref WorkshopS3Bucket
Export:
Name: !Sub '${AWS::StackName}-S3Bucket'
SageMakerRoleArn:
Description: SageMaker execution role ARN — use this when creating your notebook instance or Studio domain
Value: !GetAtt SageMakerExecutionRole.Arn
Export:
Name: !Sub '${AWS::StackName}-SageMakerRoleArn'
ClaimsMetadataTableName:
Description: DynamoDB table for claim metadata
Value: !Ref ClaimsMetadataTable
DemoClaimsMetadataTableName:
Description: DynamoDB table for demo claim metadata
Value: !Ref DemoClaimsMetadataTable
StepFunctionsRoleArn:
Description: IAM role ARN for Step Functions HITL state machines
Value: !GetAtt StepFunctionsHITLRole.Arn
UploadCommand:
Description: Run this command to upload sample claim documents to S3
Value: !Sub 'aws s3 cp 01-insurance-claims-processing/sample_data/ s3://${WorkshopS3Bucket}/claims-processing/claimant-data/ --recursive'