Skip to content

Commit

Permalink
fix(ecs): imported services don't have account & region set correctly (
Browse files Browse the repository at this point in the history
…aws#16997)

This is a fix for the region issue raised by aws#11199 allowing multi regional ecs deployments

fixes aws#11199

supersedes aws#15944, merged master and added tests

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
MarkRobbo authored and TikiTDO committed Feb 21, 2022
1 parent 211ee7a commit 4fcb80c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,7 @@ export function fromServiceAtrributes(scope: Construct, id: string, attrs: Servi
public readonly serviceName = name;
public readonly cluster = attrs.cluster;
}
return new Import(scope, id);
return new Import(scope, id, {
environmentFromArn: arn,
});
}
2 changes: 2 additions & 0 deletions packages/@aws-cdk/aws-ecs/test/ec2/ec2-service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3292,6 +3292,8 @@ describe('ec2 service', () => {
expect(service.serviceArn).toEqual('arn:aws:ecs:us-west-2:123456789012:service/my-http-service');
expect(service.serviceName).toEqual('my-http-service');

expect(service.env.account).toEqual('123456789012');
expect(service.env.region).toEqual('us-west-2');

});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2124,6 +2124,8 @@ describe('fargate service', () => {
expect(service.serviceArn).toEqual('arn:aws:ecs:us-west-2:123456789012:service/my-http-service');
expect(service.serviceName).toEqual('my-http-service');

expect(service.env.account).toEqual('123456789012');
expect(service.env.region).toEqual('us-west-2');

});

Expand Down

0 comments on commit 4fcb80c

Please sign in to comment.