Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
});
// Configuration parameters
const domainZone = HostedZone.fromLookup(this, 'Zone', { domainName: props.domainZone });
const imageRepo = Repository.fromRepositoryName(this, 'Repo', 'reinvent-trivia-backend');
const tag = (process.env.IMAGE_TAG) ? process.env.IMAGE_TAG : 'latest';
const image = ContainerImage.fromEcrRepository(imageRepo, tag)
// Lookup pre-existing TLS certificate
const certificateArn = StringParameter.fromStringParameterAttributes(this, 'CertArnParameter', {
parameterName: 'CertificateArn-' + props.domainName
}).stringValue;
const certificate = Certificate.fromCertificateArn(this, 'Cert', certificateArn);
// Fargate service + load balancer
new ApplicationLoadBalancedFargateService(this, 'Service', {
cluster,
taskImageOptions: { image },
desiredCount: 3,
domainName: props.domainName,
domainZone,
certificate
});
}
}
const taskDefinition = new ecs.TaskDefinition(this, 'orders-web-Task', {
compatibility: ecs.Compatibility.FARGATE,
memoryMiB: '512',
cpu: '256',
});
taskDefinition.addContainer('defaultContainer', {
image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'),
logging: new ecs.AwsLogDriver({
streamPrefix: 'coffeeshop',
})
}).addPortMappings({
containerPort: 8080
});
const fargatesvc = new ecsPatterns.ApplicationLoadBalancedFargateService(this, 'AlbSvc', {
cluster,
taskDefinition,
})
const fargateTaskRole = fargatesvc.service.taskDefinition.taskRole;
fargateTaskRole.addToPolicy(new iam.PolicyStatement({
resources: ['*'],
actions: ['events:*']
}));
const orderTable = new dynamodb.Table(this, 'Order', {
partitionKey: { name: 'seqNo', type: dynamodb.AttributeType.NUMBER },
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST,
tableName: 'Order',
});
orderTable.grantFullAccess(fargateTaskRole);