-
Notifications
You must be signed in to change notification settings - Fork 1
/
amp-ecs.cfndsl.rb
63 lines (51 loc) · 2.12 KB
/
amp-ecs.cfndsl.rb
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
require 'yaml'
CloudFormation do
export = external_parameters.fetch(:export_name, external_parameters[:component_name])
tags = instance_userdata = external_parameters.fetch(:tags, [])
tags << { Key: 'Name', Value: FnSub("${EnvironmentName}-#{external_parameters[:component_name]}") }
tags << { Key: 'Environment', Value: Ref(:EnvironmentName) }
tags << { Key: 'EnvironmentType', Value: Ref(:EnvironmentType) }
APS_Workspace(:APSWorkspace) do
Alias FnSub("${EnvironmentName}-#{external_parameters[:component_name]}")
Tags tags
end
ecs_aot_config = external_parameters.fetch(:aot_config_content, external_parameters[:default_aot_config_content])
aot_ecs_observer = external_parameters[:aot_ecs_observer]
ecs_aot_config['extensions']['ecs_observer'].merge!(aot_ecs_observer)
SSM_Parameter(:AotConfig) do
Name FnSub('/${EnvironmentName}/amp-ecs/AOT_CONFIG_CONTENT')
Type 'String'
Value FnSub("#{YAML.dump(ecs_aot_config)}")
Description 'AWS OpenTelemetry ECS Exporter Config'
end
Condition(:CreateGrafanaDataSourceRole, FnNot(FnEquals(Ref(:GrafanaAccountId), "")))
policy_document = {
Version: '2012-10-17',
Statement: [{
Effect: 'Allow',
Principal: {
AWS: FnSub("arn:aws:iam::${GrafanaAccountId}:root")
},
Action: 'sts:AssumeRole'
}]
}
IAM_Role(:GrafanaDataSourceRole) do
Condition(:CreateGrafanaDataSourceRole)
RoleName FnSub('${EnvironmentName}-GrafanaDataSourceRole')
AssumeRolePolicyDocument policy_document
Path '/'
Policies(iam_role_policies(external_parameters[:grafana_iam_policies]))
end
Output(:APSWorkspaceArn) {
Value(Ref(:APSWorkspace))
Export FnSub("${EnvironmentName}-#{export}-APSWorkspace")
}
Output(:WorkspaceId) {
Value(FnGetAtt(:APSWorkspace, 'WorkspaceId'))
Export FnSub("${EnvironmentName}-#{export}-WorkspaceId")
}
Output(:PrometheusEndpoint) {
Value(FnGetAtt(:APSWorkspace, 'PrometheusEndpoint'))
Export FnSub("${EnvironmentName}-#{export}-PrometheusEndpoint")
}
end