Skip to content

aws-ec2/lib/security-group: Trivial mistake in validation error message for egressRule when allowAllOutbound=true #36551

@jortkoopmans

Description

@jortkoopmans

Describe the bug

Trivial mistake/typo in validation error message, clearly it should be allowAllOutbound for ipv4 and allowAllIpv6Outbound for ipv6.

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Library Version

No response

Expected Behavior

Error message:

Cannot add an "all traffic" egress rule in this way; set allowAllOutbound=true (for ipv4) or allowAllIpv6Outbound=true (for ipv6) on the SecurityGroup instead.

Current Behavior

Error message:

Cannot add an "all traffic" egress rule in this way; set allowAllOutbound=true (for ipv6) or allowAllIpv6Outbound=true (for ipv6) on the SecurityGroup instead.

Reproduction Steps

Combine allowAllOutbound=false with some egress rule effectively allowing all (according to the isAllTrafficRule check)

Something like:

import { App, Stack } from 'aws-cdk-lib';
import { IpAddresses, Peer, Port, SecurityGroup, Vpc } from 'aws-cdk-lib/aws-ec2';
const app = new App();
const stack = new Stack(app, 'TestStack');
const somevpc = new Vpc(stack, 'SomeVPC', {
  ipAddresses: IpAddresses.cidr('10.0.0.0/16')
});
const sg = new SecurityGroup(stack, 'mySecurityGroup', {
  allowAllOutbound: false,
  description: 'My security group',
  vpc: somevpc
});

sg.addEgressRule(Peer.anyIpv4(), Port.allTraffic(), 'Effectively allowing all outbound traffic');

Possible Solution

See PR

Additional Information/Context

No response

AWS CDK Library version (aws-cdk-lib)

2.230.0

AWS CDK CLI version

2.143.0

Node.js Version

v22.21.1

OS

Linux

Language

TypeScript

Language Version

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-ec2Related to Amazon Elastic Compute CloudbugThis issue is a bug.effort/smallSmall work item – less than a day of effortp3

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions