Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure unique resources ID are created #118

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ export class DummyTaskDefinition extends Construct implements IDummyTaskDefiniti
constructor(scope: Construct, id: string, props: DummyTaskDefinitionProps) {
super(scope, id);

this.executionRole = new Role(this, 'ExecutionRole', {
this.executionRole = new Role(this, `ExecutionRole-${id}`, {
assumedBy: new ServicePrincipal('ecs-tasks.amazonaws.com'),
managedPolicies: [ManagedPolicy.fromAwsManagedPolicyName('service-role/AmazonECSTaskExecutionRolePolicy')],
});

const serviceToken = CustomResourceProvider.getOrCreate(this, 'Custom::DummyTaskDefinition', {
const serviceToken = CustomResourceProvider.getOrCreate(this, `Custom::DummyTaskDef-${id}`, {
codeDirectory: path.join(__dirname, 'lambdas', 'dummy-task-definition'),
runtime: CustomResourceProviderRuntime.NODEJS_12_X,
policyStatements: [
Expand All @@ -81,7 +81,7 @@ export class DummyTaskDefinition extends Construct implements IDummyTaskDefiniti
this.containerName = props.containerName ?? 'sample-website';
this.containerPort = props.containerPort ?? 80;

const taskDefinition = new CustomResource(this, 'CustomResource', {
const taskDefinition = new CustomResource(this, `CustomResource-${id}`, {
serviceToken,
resourceType: 'Custom::DummyTaskDefinition',
properties: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class EcsDeploymentConfig extends Resource implements IEcsDeploymentConfi
constructor(scope: Construct, id: string, props: EcsDeploymentConfigurationProps) {
super(scope, id);

const cfnDeploymentConfig = new CfnDeploymentConfig(this, 'EcsDeploymentConfiguration', {
const cfnDeploymentConfig = new CfnDeploymentConfig(this, `EcsDeploymentConfig-${id}`, {
computePlatform: 'ECS',
...props,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,16 @@ export class EcsDeploymentGroup extends Resource implements IEcsDeploymentGroup
throw new Error('Invalid TerminationWaitTimeInMinutes: The maximum setting is 2880 minutes (2 days).');
}

const codeDeployEcsRole = new Role(this, 'EcsCodeDeployRole', {
const codeDeployEcsRole = new Role(this, `${id}-ECSRole`, {
assumedBy: new ServicePrincipal('codedeploy.amazonaws.com'),
managedPolicies: [ManagedPolicy.fromAwsManagedPolicyName('AWSCodeDeployRoleForECS')],
});

this.application = new EcsApplication(this, 'EcsApplication', {
this.application = new EcsApplication(this, `EcsApplication-${id}`, {
applicationName,
});

const serviceToken = CustomResourceProvider.getOrCreate(this, 'Custom::EcsDeploymentGroup', {
const serviceToken = CustomResourceProvider.getOrCreate(this, `Custom::EcsDepGroup-${id}`, {
codeDirectory: path.join(__dirname, 'lambdas', 'ecs-deployment-group'),
runtime: CustomResourceProviderRuntime.NODEJS_12_X,
policyStatements: [
Expand All @@ -128,7 +128,7 @@ export class EcsDeploymentGroup extends Resource implements IEcsDeploymentGroup
this.node.addDependency(props.deploymentConfig);
}

const ecsDeploymentGroup = new CustomResource(this, 'CustomResource', {
const ecsDeploymentGroup = new CustomResource(this, `CustomResource-${id}`, {
serviceToken,
resourceType: 'Custom::EcsDeploymentGroup',
properties: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ export class EcsService extends Construct implements IConnectable, IEcsService {
const { vpc } = cluster;

const securityGroups = props.securityGroups || [
new SecurityGroup(this, 'SecurityGroup', {
new SecurityGroup(this, `SecurityGroup-${id}`, {
description: `Security group for ${this.node.id} service`,
vpc,
}),
];

const serviceToken = CustomResourceProvider.getOrCreate(this, 'Custom::BlueGreenService', {
const serviceToken = CustomResourceProvider.getOrCreate(this, `Custom::BlueGreenService-${id}`, {
codeDirectory: path.join(__dirname, 'lambdas', 'ecs-service'),
runtime: CustomResourceProviderRuntime.NODEJS_12_X,
policyStatements: [
Expand All @@ -104,7 +104,7 @@ export class EcsService extends Construct implements IConnectable, IEcsService {
],
});

const service = new CustomResource(this, 'CustomResource', {
const service = new CustomResource(this, `CustomResource-${id}`, {
serviceToken,
resourceType: 'Custom::BlueGreenService',
properties: {
Expand Down