Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected getDefaultCluster(scope: Construct, vpc?: IVpc): Cluster {
// magic string to avoid collision with user-defined constructs
const DEFAULT_CLUSTER_ID = `EcsDefaultClusterMnL3mNNYN${vpc ? vpc.node.id : ''}`;
const stack = Stack.of(scope);
return stack.node.tryFindChild(DEFAULT_CLUSTER_ID) as Cluster || new Cluster(stack, DEFAULT_CLUSTER_ID, { vpc });
}
protected getDefaultCluster(scope: cdk.Construct, vpc?: IVpc): Cluster {
// magic string to avoid collision with user-defined constructs
const DEFAULT_CLUSTER_ID = `EcsDefaultClusterMnL3mNNYN${vpc ? vpc.node.id : ''}`;
const stack = cdk.Stack.of(scope);
return stack.node.tryFindChild(DEFAULT_CLUSTER_ID) as Cluster || new Cluster(stack, DEFAULT_CLUSTER_ID, { vpc });
}
protected getDefaultCluster(scope: cdk.Construct, vpc?: IVpc): Cluster {
// magic string to avoid collision with user-defined constructs
const DEFAULT_CLUSTER_ID = `EcsDefaultClusterMnL3mNNYN${vpc ? vpc.node.id : ''}`;
const stack = cdk.Stack.of(scope);
return stack.node.tryFindChild(DEFAULT_CLUSTER_ID) as Cluster || new Cluster(stack, DEFAULT_CLUSTER_ID, { vpc });
}
}
},
// cache:{
// paths:[
// '/root/.m2/**/*',
// ]
// }
})
});
// const vpc = Vpc.fromLookup(this, 'CoffeeShopCdkStack/CoffeeShopVPC',{
// vpcName: 'CoffeeShopCdkStack/CoffeeShopVPC',
// isDefault: false,
// });
const cluster = new ecs.Cluster(this, 'Cluster', {
clusterName: 'coffeeshop',
vpc
});
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',
constructor(parent: cdk.App, name: string, props: TriviaBackendStackProps) {
super(parent, name, props);
// Network infrastructure
const vpc = new Vpc(this, 'VPC', { maxAzs: 2 });
const cluster = new Cluster(this, 'Cluster', {
clusterName: props.domainName.replace(/\./g, '-'),
vpc
});
// 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);
protected getDefaultCluster(scope: Construct, vpc?: IVpc): Cluster {
// magic string to avoid collision with user-defined constructs
const DEFAULT_CLUSTER_ID = `EcsDefaultClusterMnL3mNNYN${vpc ? vpc.node.id : ''}`;
const stack = Stack.of(scope);
return stack.node.tryFindChild(DEFAULT_CLUSTER_ID) as Cluster || new Cluster(stack, DEFAULT_CLUSTER_ID, { vpc });
}
constructor(parent, id, props) {
super(parent, id, props);
const vpc = new ec2.Vpc(this, 'GreetingVpc', { maxAZs: 2 });
// Create an ECS cluster
const cluster = new ecs.Cluster(this, 'Cluster', { vpc });
// Add capacity to it
cluster.addCapacity('greeter-capacity', {
instanceType: new ec2.InstanceType('t3.xlarge'),
minCapacity: 3,
maxCapacity: 3
});
// Name service
const nameTaskDefinition = new ecs.Ec2TaskDefinition(this, 'name-task-definition', {});
const nameContainer = nameTaskDefinition.addContainer('name', {
image: ecs.ContainerImage.fromRegistry('nathanpeck/name'),
memoryLimitMiB: 128
});