Skip to content

ecs-patterns: enable to specify securityGroups in NetworkLoadBalancedFargateService #29430

@wafuwafu13

Description

@wafuwafu13

Describe the feature

We can't specify securityGroups in NetworkLoadBalancedFargateService now.

Use Case

Default is an empty array, so we have to specify securityGroups.

/**
* After the implementation of `IConnectable` (see https://github.com/aws/aws-cdk/pull/28494), the default
* value for `securityGroups` is set by the `ec2.Connections` constructor to an empty array.
* To keep backward compatibility (`securityGroups` is `undefined` if the related property is not specified)
* a getter has been added.
*/
public get securityGroups(): string[] | undefined {
return this.isSecurityGroupsPropertyDefined || this.connections.securityGroups.length
? this.connections.securityGroups.map(sg => sg.securityGroupId)
: undefined;
}

Proposed Solution

Add securityGroups property to NetworkLoadBalancedFargateServiceProps.

/**
* The properties for the NetworkLoadBalancedFargateService service.
*/
export interface NetworkLoadBalancedFargateServiceProps extends NetworkLoadBalancedServiceBaseProps, FargateServiceBaseProps {
/**
* Determines whether the service will be assigned a public IP address.
*
* @default false
*/
readonly assignPublicIp?: boolean;
/**
* The subnets to associate with the service.
*
* @default - Public subnets if `assignPublicIp` is set, otherwise the first available one of Private, Isolated, Public, in that order.
*/
readonly taskSubnets?: SubnetSelection;
}

Other Information

ApplicationLoadBalancedFargateServiceProps has securityGroups property already.

/**
* The security groups to associate with the service. If you do not specify a security group, a new security group is created.
*
* @default - A new security group is created.
*/
readonly securityGroups?: ISecurityGroup[];

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

v2.132.0

Environment details (OS name and version, etc.)

Darwin tagawahirotakanoMacBook-Pro.local 23.2.0 Darwin Kernel Version 23.2.0: Wed Nov 15 21:53:18 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T6000 arm64

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions