Class CfnSecurityGroupPropsMixin

java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.mixins.preview.core.Mixin
software.amazon.awscdk.mixins.preview.services.ec2.mixins.CfnSecurityGroupPropsMixin
All Implemented Interfaces:
IMixin, software.amazon.jsii.JsiiSerializable

@Generated(value="jsii-pacmak/1.121.0 (build d7af9b9)", date="2025-12-18T18:20:25.351Z") @Stability(Stable) public class CfnSecurityGroupPropsMixin extends Mixin implements IMixin
Specifies a security group.

You must specify ingress rules to allow inbound traffic. By default, no inbound traffic is allowed.

When you create a security group, if you do not add egress rules, we add egress rules that allow all outbound IPv4 and IPv6 traffic. Otherwise, we do not add them. After the security group is created, if you remove all egress rules that you added, we do not add egress rules, so no outbound traffic is allowed.

If you modify a rule, CloudFormation removes the existing rule and then adds a new rule. There is a brief period when neither the original rule or the new rule exists, so the corresponding traffic is dropped.

This type supports updates. For more information about updating stacks, see AWS CloudFormation Stacks Updates .

To cross-reference two security groups in the ingress and egress rules of those security groups, use the AWS::EC2::SecurityGroupEgress and AWS::EC2::SecurityGroupIngress resources to define your rules. Do not use the embedded ingress and egress rules in the AWS::EC2::SecurityGroup . Doing so creates a circular dependency, which CloudFormation doesn't allow.

Example:

 // The code below shows an example of how to instantiate this type.
 // The values are placeholders you should change.
 import software.amazon.awscdk.mixins.preview.mixins.*;
 import software.amazon.awscdk.mixins.preview.services.ec2.mixins.*;
 CfnSecurityGroupPropsMixin cfnSecurityGroupPropsMixin = CfnSecurityGroupPropsMixin.Builder.create(CfnSecurityGroupMixinProps.builder()
         .groupDescription("groupDescription")
         .groupName("groupName")
         .securityGroupEgress(List.of(EgressProperty.builder()
                 .cidrIp("cidrIp")
                 .cidrIpv6("cidrIpv6")
                 .description("description")
                 .destinationPrefixListId("destinationPrefixListId")
                 .destinationSecurityGroupId("destinationSecurityGroupId")
                 .fromPort(123)
                 .ipProtocol("ipProtocol")
                 .toPort(123)
                 .build()))
         .securityGroupIngress(List.of(IngressProperty.builder()
                 .cidrIp("cidrIp")
                 .cidrIpv6("cidrIpv6")
                 .description("description")
                 .fromPort(123)
                 .ipProtocol("ipProtocol")
                 .sourcePrefixListId("sourcePrefixListId")
                 .sourceSecurityGroupId("sourceSecurityGroupId")
                 .sourceSecurityGroupName("sourceSecurityGroupName")
                 .sourceSecurityGroupOwnerId("sourceSecurityGroupOwnerId")
                 .toPort(123)
                 .build()))
         .tags(List.of(CfnTag.builder()
                 .key("key")
                 .value("value")
                 .build()))
         .vpcId("vpcId")
         .build())
 .strategy(PropertyMergeStrategy.OVERRIDE)
 .build();
 

See Also:
  • Field Details

    • CFN_PROPERTY_KEYS

      @Stability(Stable) protected static final List<String> CFN_PROPERTY_KEYS
  • Constructor Details

    • CfnSecurityGroupPropsMixin

      protected CfnSecurityGroupPropsMixin(software.amazon.jsii.JsiiObjectRef objRef)
    • CfnSecurityGroupPropsMixin

      protected CfnSecurityGroupPropsMixin(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • CfnSecurityGroupPropsMixin

      @Stability(Stable) public CfnSecurityGroupPropsMixin(@NotNull CfnSecurityGroupMixinProps props, @Nullable CfnPropertyMixinOptions options)
      Create a mixin to apply properties to AWS::EC2::SecurityGroup.

      Parameters:
      props - L1 properties to apply. This parameter is required.
      options - Mixin options.
    • CfnSecurityGroupPropsMixin

      @Stability(Stable) public CfnSecurityGroupPropsMixin(@NotNull CfnSecurityGroupMixinProps props)
      Create a mixin to apply properties to AWS::EC2::SecurityGroup.

      Parameters:
      props - L1 properties to apply. This parameter is required.
  • Method Details

    • applyTo

      @Stability(Stable) @NotNull public software.constructs.IConstruct applyTo(@NotNull software.constructs.IConstruct construct)
      Apply the mixin properties to the construct.

      Specified by:
      applyTo in interface IMixin
      Specified by:
      applyTo in class Mixin
      Parameters:
      construct - This parameter is required.
    • supports

      @Stability(Stable) @NotNull public Boolean supports(@NotNull software.constructs.IConstruct construct)
      Check if this mixin supports the given construct.

      Specified by:
      supports in interface IMixin
      Overrides:
      supports in class Mixin
      Parameters:
      construct - This parameter is required.
    • getProps

      @Stability(Stable) @NotNull protected CfnSecurityGroupMixinProps getProps()
    • getStrategy

      @Stability(Stable) @NotNull protected PropertyMergeStrategy getStrategy()