CfnSecurityGroupProps Struct
Properties for defining a CfnSecurityGroup.
Example
ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_ec2 as ec2 } from 'aws-cdk-lib';
const cfnSecurityGroupProps: ec2.CfnSecurityGroupProps = {
groupDescription: 'groupDescription',
// the properties below are optional
groupName: 'groupName',
securityGroupEgress: [{
ipProtocol: 'ipProtocol',
// the properties below are optional
cidrIp: 'cidrIp',
cidrIpv6: 'cidrIpv6',
description: 'description',
destinationPrefixListId: 'destinationPrefixListId',
destinationSecurityGroupId: 'destinationSecurityGroupId',
fromPort: 123,
toPort: 123,
}],
securityGroupIngress: [{
ipProtocol: 'ipProtocol',
// the properties below are optional
cidrIp: 'cidrIp',
cidrIpv6: 'cidrIpv6',
description: 'description',
fromPort: 123,
sourcePrefixListId: 'sourcePrefixListId',
sourceSecurityGroupId: 'sourceSecurityGroupId',
sourceSecurityGroupName: 'sourceSecurityGroupName',
sourceSecurityGroupOwnerId: 'sourceSecurityGroupOwnerId',
toPort: 123,
}],
tags: [{
key: 'key',
value: 'value',
}],
vpcId: 'vpcId',
};
python
from aws_cdk import CfnTag
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_ec2 as ec2
cfn_security_group_props = ec2.CfnSecurityGroupProps(
group_description="groupDescription",
# the properties below are optional
group_name="groupName",
security_group_egress=[ec2.CfnSecurityGroup.EgressProperty(
ip_protocol="ipProtocol",
# the properties below are optional
cidr_ip="cidrIp",
cidr_ipv6="cidrIpv6",
description="description",
destination_prefix_list_id="destinationPrefixListId",
destination_security_group_id="destinationSecurityGroupId",
from_port=123,
to_port=123
)],
security_group_ingress=[ec2.CfnSecurityGroup.IngressProperty(
ip_protocol="ipProtocol",
# the properties below are optional
cidr_ip="cidrIp",
cidr_ipv6="cidrIpv6",
description="description",
from_port=123,
source_prefix_list_id="sourcePrefixListId",
source_security_group_id="sourceSecurityGroupId",
source_security_group_name="sourceSecurityGroupName",
source_security_group_owner_id="sourceSecurityGroupOwnerId",
to_port=123
)],
tags=[CfnTag(
key="key",
value="value"
)],
vpc_id="vpcId"
)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.ec2.*;
CfnSecurityGroupProps cfnSecurityGroupProps = CfnSecurityGroupProps.builder()
.groupDescription("groupDescription")
// the properties below are optional
.groupName("groupName")
.securityGroupEgress(List.of(EgressProperty.builder()
.ipProtocol("ipProtocol")
// the properties below are optional
.cidrIp("cidrIp")
.cidrIpv6("cidrIpv6")
.description("description")
.destinationPrefixListId("destinationPrefixListId")
.destinationSecurityGroupId("destinationSecurityGroupId")
.fromPort(123)
.toPort(123)
.build()))
.securityGroupIngress(List.of(IngressProperty.builder()
.ipProtocol("ipProtocol")
// the properties below are optional
.cidrIp("cidrIp")
.cidrIpv6("cidrIpv6")
.description("description")
.fromPort(123)
.sourcePrefixListId("sourcePrefixListId")
.sourceSecurityGroupId("sourceSecurityGroupId")
.sourceSecurityGroupName("sourceSecurityGroupName")
.sourceSecurityGroupOwnerId("sourceSecurityGroupOwnerId")
.toPort(123)
.build()))
.tags(List.of(CfnTag.builder()
.key("key")
.value("value")
.build()))
.vpcId("vpcId")
.build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.EC2;
var cfnSecurityGroupProps = new CfnSecurityGroupProps {
GroupDescription = "groupDescription",
// the properties below are optional
GroupName = "groupName",
SecurityGroupEgress = new [] { new EgressProperty {
IpProtocol = "ipProtocol",
// the properties below are optional
CidrIp = "cidrIp",
CidrIpv6 = "cidrIpv6",
Description = "description",
DestinationPrefixListId = "destinationPrefixListId",
DestinationSecurityGroupId = "destinationSecurityGroupId",
FromPort = 123,
ToPort = 123
} },
SecurityGroupIngress = new [] { new IngressProperty {
IpProtocol = "ipProtocol",
// the properties below are optional
CidrIp = "cidrIp",
CidrIpv6 = "cidrIpv6",
Description = "description",
FromPort = 123,
SourcePrefixListId = "sourcePrefixListId",
SourceSecurityGroupId = "sourceSecurityGroupId",
SourceSecurityGroupName = "sourceSecurityGroupName",
SourceSecurityGroupOwnerId = "sourceSecurityGroupOwnerId",
ToPort = 123
} },
Tags = new [] { new CfnTag {
Key = "key",
Value = "value"
} },
VpcId = "vpcId"
};
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"
cfnSecurityGroupProps := &CfnSecurityGroupProps{
GroupDescription: jsii.String("groupDescription"),
// the properties below are optional
GroupName: jsii.String("groupName"),
SecurityGroupEgress: []interface{}{
&EgressProperty{
IpProtocol: jsii.String("ipProtocol"),
// the properties below are optional
CidrIp: jsii.String("cidrIp"),
CidrIpv6: jsii.String("cidrIpv6"),
Description: jsii.String("description"),
DestinationPrefixListId: jsii.String("destinationPrefixListId"),
DestinationSecurityGroupId: jsii.String("destinationSecurityGroupId"),
FromPort: jsii.Number(123),
ToPort: jsii.Number(123),
},
},
SecurityGroupIngress: []interface{}{
&IngressProperty{
IpProtocol: jsii.String("ipProtocol"),
// the properties below are optional
CidrIp: jsii.String("cidrIp"),
CidrIpv6: jsii.String("cidrIpv6"),
Description: jsii.String("description"),
FromPort: jsii.Number(123),
SourcePrefixListId: jsii.String("sourcePrefixListId"),
SourceSecurityGroupId: jsii.String("sourceSecurityGroupId"),
SourceSecurityGroupName: jsii.String("sourceSecurityGroupName"),
SourceSecurityGroupOwnerId: jsii.String("sourceSecurityGroupOwnerId"),
ToPort: jsii.Number(123),
},
},
Tags: []CfnTag{
&CfnTag{
Key: jsii.String("key"),
Value: jsii.String("value"),
},
},
VpcId: jsii.String("vpcId"),
}
Properties
groupDescriptionstringgroup_descriptionstrgroupDescriptionStringGroupDescriptionstringGroupDescription*stringrequired#A description for the security group.
Constraints: Up to 255 characters in length
Valid characters: a-z, A-Z, 0-9, spaces, and ._-😕()#,@[]+=&;{}!$*
groupNameoptionalstringgroup_nameoptionalstrgroupNameoptionalStringGroupNameoptionalstringGroupNameoptional*string#The name of the security group. Names are case-insensitive and must be unique within the VPC.
Constraints: Up to 255 characters in length. Can't start with sg- .
Valid characters: a-z, A-Z, 0-9, spaces, and ._-😕()#,@[]+=&;{}!$*
securityGroupEgressoptionalIResolvable | IResolvable | CfnSecurityGroup.EgressProperty[]security_group_egressoptionaltyping.Union[IResolvable, typing.List[typing.Union[IResolvable, EgressProperty]]]securityGroupEgressoptionalIResolvableSecurityGroupEgressoptionalIResolvableSecurityGroupEgressoptionalinterface{}#The outbound rules associated with the security group.
securityGroupIngressoptionalIResolvable | IResolvable | CfnSecurityGroup.IngressProperty[]security_group_ingressoptionaltyping.Union[IResolvable, typing.List[typing.Union[IResolvable, IngressProperty]]]securityGroupIngressoptionalIResolvableSecurityGroupIngressoptionalIResolvableSecurityGroupIngressoptionalinterface{}#The inbound rules associated with the security group.
tagsoptionalCfnTag[]tagsoptionaltyping.List[CfnTag]tagsoptionalList<CfnTag>TagsoptionalCfnTag[]Tagsoptional*[]CfnTag#Any tags assigned to the security group.
vpcIdoptionalstring | IVPCRefvpc_idoptionaltyping.Union[str, IVPCRef]vpcIdoptionalStringVpcIdoptionalstringVpcIdoptionalinterface{}#The ID of the VPC for the security group.
If you do not specify a VPC, the default is to use the default VPC for the Region. If there's no specified VPC and no default VPC, security group creation fails.