Skip to content

Commit

Permalink
fix(ec2): securityGroups is mandatory in fromClusterAttributes (#25976)
Browse files Browse the repository at this point in the history
The `securityGroups` is passed down to create a new `ec2.Connections`, where this property is already optional. Making it optional in `fromClusterAttributes` as well.


Closes #11146 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
otaviomacedo authored Jun 15, 2023
1 parent d9427e2 commit d8f5e2d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/aws-cdk-lib/aws-ecs/lib/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -765,8 +765,10 @@ export interface ClusterAttributes {

/**
* The security groups associated with the container instances registered to the cluster.
*
* @default - no security groups
*/
readonly securityGroups: ec2.ISecurityGroup[];
readonly securityGroups?: ec2.ISecurityGroup[];

/**
* Specifies whether the cluster has EC2 instance capacity.
Expand Down
14 changes: 14 additions & 0 deletions packages/aws-cdk-lib/aws-ecs/test/cluster.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1374,6 +1374,20 @@ describe('cluster', () => {

});

test('Security groups are optonal for imported clusters', () => {
// GIVEN
const stack = new cdk.Stack();
const vpc = new ec2.Vpc(stack, 'Vpc');

const cluster = ecs.Cluster.fromClusterAttributes(stack, 'Cluster', {
clusterName: 'cluster-name',
vpc,
});

// THEN
expect(cluster.connections.securityGroups).toEqual([]);
});

test('Metric', () => {
// GIVEN
const stack = new cdk.Stack();
Expand Down

0 comments on commit d8f5e2d

Please sign in to comment.