Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Principal: {
Service: [ "ec2.amazonaws.com" ]
},
Action: [ "sts:AssumeRole" ]
}]
},
Policies: [{
PolicyName: "AccessToDatabaseDump",
PolicyDocument: {
Version: "2012-10-17",
Statement:[{
Action: [ 's3:ListBucket'],
Effect: 'Allow',
Resource: [ cf.join('',
['arn:aws:s3:::',
cf.select(0,
cf.split('/',
cf.select(1,
cf.split('s3://', cf.ref('DatabaseDump'))
)
)
)
]
)]
}, {
Action: [
's3:GetObject',
's3:GetObjectAcl',
's3:ListObjects',
's3:ListBucket'
],
Effect: 'Allow',
},
Action: [ "sts:AssumeRole" ]
}]
},
Policies: [{
PolicyName: "AccessToDatabaseDump",
PolicyDocument: {
Version: "2012-10-17",
Statement:[{
Action: [ 's3:ListBucket'],
Effect: 'Allow',
Resource: [ cf.join('',
['arn:aws:s3:::',
cf.select(0,
cf.split('/',
cf.select(1,
cf.split('s3://', cf.ref('DatabaseDump'))
)
)
)
]
)]
}, {
Action: [
's3:GetObject',
's3:GetObjectAcl',
's3:ListObjects',
's3:ListBucket'
],
Effect: 'Allow',
Resource: [cf.join('',
['arn:aws:s3:::',
)
)
)
]
)]
}, {
Action: [
's3:GetObject',
's3:GetObjectAcl',
's3:ListObjects',
's3:ListBucket'
],
Effect: 'Allow',
Resource: [cf.join('',
['arn:aws:s3:::',
cf.select(1,
cf.split('s3://', cf.ref('DatabaseDump'))
)]
)]
}]
}
}],
RoleName: cf.join('-', [cf.stackName, 'ec2', 'database-dump-access', 'role'])
}
},
TaskingManagerEC2InstanceProfile: {
Type: "AWS::IAM::InstanceProfile",
Properties: {
Roles: cf.if('DatabaseDumpFileGiven', [cf.ref('TaskingManagerDatabaseDumpAccessRole')], [cf.ref('TaskingManagerEC2Role')]),
InstanceProfileName: cf.join('-', [cf.stackName, 'ec2', 'instance', 'profile'])
}
},
Effect: 'Allow',
Resource: ['arn:aws:cloudformation:*']
}]
}
}, {
PolicyName: "AccessToDatabaseDump",
PolicyDocument: {
Version: "2012-10-17",
Statement:[{
Action: [ 's3:ListBucket'],
Effect: 'Allow',
Resource: [ cf.join('',
['arn:aws:s3:::',
cf.select(0,
cf.split('/',
cf.select(1,
cf.split('s3://', cf.ref('DatabaseDump'))
)
)
)
]
)]
}, {
Action: [
's3:GetObject',
's3:GetObjectAcl',
's3:ListObjects',
's3:ListBucket'
],
Effect: 'Allow',
Resource: [cf.join('',
['arn:aws:s3:::',
)
)
)
]
)]
}, {
Action: [
's3:GetObject',
's3:GetObjectAcl',
's3:ListObjects',
's3:ListBucket'
],
Effect: 'Allow',
Resource: [cf.join('',
['arn:aws:s3:::',
cf.select(1,
cf.split('s3://', cf.ref('DatabaseDump'))
)]
)]
}]
}
}],
RoleName: cf.join('-', [cf.stackName, 'ec2', 'database-dump-access', 'role'])
}
},
TaskingManagerEC2InstanceProfile: {
Type: "AWS::IAM::InstanceProfile",
Properties: {
Roles: cf.if('DatabaseDumpFileGiven', [cf.ref('TaskingManagerEC2Role'), cf.ref('TaskingManagerDatabaseDumpAccessRole')], [cf.ref('TaskingManagerEC2Role')]),
InstanceProfileName: cf.join('-', [cf.stackName, 'ec2', 'instance', 'profile'])
}
},
'cloudformation:DescribeStackResource'
],
Effect: 'Allow',
Resource: ['arn:aws:cloudformation:*']
}]
}
}, {
PolicyName: "AccessToDatabaseDump",
PolicyDocument: {
Version: "2012-10-17",
Statement:[{
Action: [ 's3:ListBucket'],
Effect: 'Allow',
Resource: [ cf.join('',
['arn:aws:s3:::',
cf.select(0,
cf.split('/',
cf.select(1,
cf.split('s3://', cf.ref('DatabaseDump'))
)
)
)
]
)]
}, {
Action: [
's3:GetObject',
's3:GetObjectAcl',
's3:ListObjects',
's3:ListBucket'
],
Effect: 'Allow',
Properties: {
AutoScalingGroupName: cf.ref('TaskingManagerASG'),
PolicyType: 'TargetTrackingScaling',
TargetTrackingConfiguration: {
TargetValue: 600,
PredefinedMetricSpecification: {
PredefinedMetricType: 'ALBRequestCountPerTarget',
ResourceLabel: cf.join('/', [
cf.select(1,
cf.split('loadbalancer/',
cf.select(5,
cf.split(':', cf.ref("TaskingManagerLoadBalancer"))
)
)
),
cf.select(5,
cf.split(':', cf.ref("TaskingManagerTargetGroup"))
)
])
}
},
Cooldown: 600
}
},
TaskingManagerLaunchConfiguration: {
Type: "AWS::AutoScaling::LaunchConfiguration",
Metadata: {
"AWS::CloudFormation::Init": {
"configSets": {
"default": [
"01_setupCfnHup",
"02_config-amazon-cloudwatch-agent",
}
}
},
TaskingManagerScaleUp: {
Type: "AWS::AutoScaling::ScalingPolicy",
Properties: {
AutoScalingGroupName: cf.ref('TaskingManagerASG'),
PolicyType: 'TargetTrackingScaling',
TargetTrackingConfiguration: {
TargetValue: 600,
PredefinedMetricSpecification: {
PredefinedMetricType: 'ALBRequestCountPerTarget',
ResourceLabel: cf.join('/', [
cf.select(1,
cf.split('loadbalancer/',
cf.select(5,
cf.split(':', cf.ref("TaskingManagerLoadBalancer"))
)
)
),
cf.select(5,
cf.split(':', cf.ref("TaskingManagerTargetGroup"))
)
])
}
},
Cooldown: 600
}
},
TaskingManagerLaunchConfiguration: {
Type: "AWS::AutoScaling::LaunchConfiguration",
Metadata: {