Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
)
)
]
)]
}, {
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'])
}
},
TaskingManagerLoadBalancer: {
TargetType: "ip",
Matcher: {
HttpCode: "200,202,302,304"
}
}
},
MLEnablerALB: {
Type: "AWS::ElasticLoadBalancingV2::LoadBalancer",
Properties: {
Name: cf.stackName,
SecurityGroups: [
cf.importValue(
cf.join("-", ["hotosm-network-production-production-elbs-security-group", cf.region])
)
],
Subnets: cf.split(",", cf.ref("ELBSubnets")),
Type: "application"
}
},
MLEnablerHTTPSListener: {
Type: 'AWS::ElasticLoadBalancingV2::Listener',
Properties: {
Certificates: [ {
CertificateArn: cf.arn('acm', cf.ref('SSLCertificateIdentifier'))
}],
DefaultActions: [{
Type: 'forward',
TargetGroupArn: cf.ref('MLEnablerTargetGroup')
}],
LoadBalancerArn: cf.ref('MLEnablerALB'),
Port: 443,
Protocol: 'HTTPS'
],
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('',
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'])
}
},
TaskingManagerLoadBalancer: {
Type: 'AWS::ElasticLoadBalancingV2::LoadBalancer',
Properties: {
Name: cf.stackName,
SecurityGroups: [cf.importValue(cf.join('-', ['hotosm-network-production', cf.ref('Environment'), 'elbs-security-group', cf.region]))],
Subnets: cf.split(',', cf.ref('ELBSubnets')),
Type: 'application'
}
},
TaskingManagerTargetGroup: {
Type: 'AWS::ElasticLoadBalancingV2::TargetGroup',
Properties: {
HealthCheckIntervalSeconds: 60,
HealthCheckPort: 8000,
HealthCheckProtocol: 'HTTP',
HealthCheckTimeoutSeconds: 10,
HealthyThresholdCount: 3,
UnhealthyThresholdCount: 3,
Port: 8000,
Protocol: 'HTTP',
VpcId: cf.importValue(cf.join('-', ['hotosm-network-production', 'default-vpc', cf.region])),
Matcher: {
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',
Resource: [cf.join('',
WaitOnResourceSignals: true
}
}
},
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",
Type: "AWS::IAM::InstanceProfile",
Properties: {
Roles: [cf.ref("VisualizeChangeEC2Role")],
InstanceProfileName: cf.join("-", [cf.stackName, "ec2", "instance", "profile"])
}
},
VisualizeChangeLoadBalancer: {
Type: "AWS::ElasticLoadBalancingV2::LoadBalancer",
Properties: {
Name: cf.stackName,
SecurityGroups: [
cf.importValue(
cf.join("-", ["hotosm-network-production", cf.ref("Environment"), "elbs-security-group", cf.region])
)
],
Subnets: cf.split(",", cf.ref("ELBSubnets")),
Type: "application"
}
},
VisualizeChangeTargetGroup: {
Type: "AWS::ElasticLoadBalancingV2::TargetGroup",
Properties: {
HealthCheckIntervalSeconds: 60,
HealthCheckPort: 8000,
HealthCheckProtocol: "HTTP",
HealthCheckTimeoutSeconds: 10,
HealthyThresholdCount: 3,
UnhealthyThresholdCount: 3,
Port: 8000,
Protocol: "HTTP",
VpcId: cf.importValue(cf.join("-", ["hotosm-network-production", "default-vpc", cf.region])),
Matcher: {
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:::',
cf.select(1,
}
},
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: {
"AWS::CloudFormation::Init": {