-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.yaml
101 lines (96 loc) · 2.9 KB
/
template.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
89
90
91
92
93
94
95
96
97
98
99
100
101
Transform: AWS::Serverless-2016-10-31
Resources:
Bucket:
Type: AWS::S3::Bucket
DeletionPolicy: Retain
UpdateReplacePolicy: Retain
Properties:
BucketEncryption:
ServerSideEncryptionConfiguration:
- ServerSideEncryptionByDefault:
SSEAlgorithm: aws:kms
PublicAccessBlockConfiguration:
BlockPublicAcls: true
BlockPublicPolicy: true
IgnorePublicAcls: true
RestrictPublicBuckets: true
LifecycleConfiguration:
Rules:
- Id: AbortIncompleteMultipartUpload
AbortIncompleteMultipartUpload:
DaysAfterInitiation: 3
NoncurrentVersionExpirationInDays: 3
Status: Enabled
- Id: Expirein365Days
ExpirationInDays: 14
Status: Enabled
BucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref Bucket
PolicyDocument:
Statement:
- Effect: "Deny"
Action: "s3:*"
Principal: "*"
Resource:
- !Sub "${Bucket.Arn}/*"
- !GetAtt Bucket.Arn
Condition:
Bool:
aws:SecureTransport: false
StateMachine:
Type: AWS::Serverless::StateMachine
Properties:
DefinitionUri: state_machine.asl.json
DefinitionSubstitutions:
ReadOrganizationArn: !GetAtt ReadOrganization.Arn
ListWorkloadsArn: !GetAtt ListWorkloads.Arn
BucketName: !Ref Bucket
Policies:
- Version: 2012-10-17
Statement:
- Effect: Allow
Action: lambda:InvokeFunction
Resource:
- !GetAtt ReadOrganization.Arn
- !GetAtt ListWorkloads.Arn
- Effect: Allow
Action:
- s3:putObject
- s3:getObject
Resource:
- !Sub ${Bucket.Arn}/organization-data.json
ReadOrganization:
Type: AWS::Serverless::Function
Properties:
Description: Example function
CodeUri: read_organization
Handler: index.handler
MemorySize: 128
Runtime: python3.9
Timeout: 300
Policies:
- Version: 2012-10-17
Statement:
- Effect: Allow
Action: organizations:ListRoots
Resource: "*"
- Effect: Allow
Action:
- organizations:DescribeOrganizationalUnit
- organizations:DescribeAccount
- organizations:ListChildren
Resource:
- arn:aws:organizations::*:account/*
- arn:aws:organizations::*:ou/*
- arn:aws:organizations::*:root/*
ListWorkloads:
Type: AWS::Serverless::Function
Properties:
Description: Example function
CodeUri: list_workloads
Handler: index.handler
MemorySize: 128
Runtime: python3.9
Timeout: 60