Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
if (!props.taskDefinition.defaultContainer) {
throw new Error('A TaskDefinition must have at least one essential container');
}
super({
...props,
parameters: {
LaunchType: 'EC2',
PlacementConstraints: noEmpty(flatten((props.placementConstraints || []).map(c => c.toJson().map(uppercaseKeys)))),
PlacementStrategy: noEmpty(flatten((props.placementStrategies || []).map(c => c.toJson().map(uppercaseKeys)))),
}
});
if (props.taskDefinition.networkMode === ecs.NetworkMode.AWS_VPC) {
this.configureAwsVpcNetworking(props.cluster.vpc, undefined, props.subnets, props.securityGroup);
} else {
// Either None, Bridge or Host networking. Copy SecurityGroup from ASG.
validateNoNetworkingProps(props);
this.connections.addSecurityGroup(...props.cluster.connections.securityGroups);
}
}
}
}
const arn = this.cluster.clusterArn;
const role = singletonEventRole(this.taskDefinition, policyStatements);
const containerOverrides = this.props.containerOverrides && this.props.containerOverrides
.map(({ containerName, ...overrides }) => ({ name: containerName, ...overrides }));
const input = { containerOverrides };
const taskCount = this.taskCount;
const taskDefinitionArn = this.taskDefinition.taskDefinitionArn;
const subnetSelection = this.props.subnetSelection || { subnetType: ec2.SubnetType.PRIVATE };
const assignPublicIp = subnetSelection.subnetType === ec2.SubnetType.PUBLIC ? 'ENABLED' : 'DISABLED';
const baseEcsParameters = { taskCount, taskDefinitionArn };
const ecsParameters: events.CfnRule.EcsParametersProperty = this.taskDefinition.networkMode === ecs.NetworkMode.AWS_VPC
? {
...baseEcsParameters,
launchType: this.taskDefinition.isEc2Compatible ? 'EC2' : 'FARGATE',
networkConfiguration: {
awsVpcConfiguration: {
subnets: this.props.cluster.vpc.selectSubnets(subnetSelection).subnetIds,
assignPublicIp,
securityGroups: this.securityGroup && [this.securityGroup.securityGroupId]
}
}
}
: baseEcsParameters;
return {
id: '',
arn,