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
|
# File 'lib/jets/stack/s3_event.rb', line 15
def build_stack
bucket = @bucket_name
Jets::Stack.new_class(stack_name) do
s3_bucket_configuration(:s3_bucket_configuration,
service_token: "!GetAtt JetsS3BucketConfig.Arn",
bucket: bucket,
notification_configuration: Jets.config.s3_event.notification_configuration,
) if Jets.config.s3_event.configure_bucket
function("jets/s3_bucket_config",
role: "!GetAtt BucketConfigIamRole.Arn",
layers: ["!Ref GemLayer"],
)
sns_topic(:sns_topic)
sns_topic_policy(:sns_topic_policy,
policy_document: {
version: "2012-10-17",
statement: {
effect: "Allow",
principal: { service: "s3.amazonaws.com"},
action: "sns:Publish",
resource: "!Ref SnsTopic",
condition: {
arn_like: {
"aws:SourceArn" => "!Sub arn:aws:s3:*:*:#{bucket}"
}
}
}
},
topics: ["!Ref SnsTopic"],
)
iam_role(:bucket_config_iam_role,
assume_role_policy_document: {
version: '2012-10-17',
statement: [
effect: "Allow",
principal: {service: ["lambda.amazonaws.com"]},
action: ['sts:AssumeRole'],
]
},
path: "/",
managed_policy_arns: ["arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"],
policies: [
policy_name: "S3Policy",
policy_document: {
version: '2012-10-17',
statement: [
effect: "Allow",
action: [
's3:GetBucketNotification',
's3:PutBucketNotification',
],
resource: "*"
]
}
]
)
end
end
|