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

fix(ec2): securityGroups is mandatory in fromClusterAttributes #25976

Merged
merged 2 commits into from
Jun 15, 2023
Merged
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
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