Class CfnSecurityGroup
- All Implemented Interfaces:
IInspectable
,ITaggable
,software.amazon.jsii.JsiiSerializable
,software.constructs.IConstruct
,software.constructs.IDependable
To create a security group, use the VpcId property to specify the VPC for which to create the security group.
If you do not specify an egress rule, we add egress rules that allow IPv4 and IPv6 traffic on all ports and protocols to any destination. We do not add these rules if you specify your own egress rules.
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 AWS 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.services.ec2.*; CfnSecurityGroup cfnSecurityGroup = CfnSecurityGroup.Builder.create(this, "MyCfnSecurityGroup") .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();
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
A fluent builder forCfnSecurityGroup
.static interface
Adds the specified outbound (egress) rule to a security group.static interface
Adds an inbound (ingress) rule to a security group.Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode
Nested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$Default
Nested classes/interfaces inherited from interface software.amazon.awscdk.IInspectable
IInspectable.Jsii$Default, IInspectable.Jsii$Proxy
Nested classes/interfaces inherited from interface software.amazon.awscdk.ITaggable
ITaggable.Jsii$Default, ITaggable.Jsii$Proxy
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The CloudFormation resource type name for this resource class. -
Constructor Summary
ModifierConstructorDescriptionprotected
CfnSecurityGroup
(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protected
CfnSecurityGroup
(software.amazon.jsii.JsiiObjectRef objRef) CfnSecurityGroup
(software.constructs.Construct scope, String id, CfnSecurityGroupProps props) -
Method Summary
Modifier and TypeMethodDescriptionThe group ID of the specified security group, such assg-94b3a1f6
.The group name or group ID depending on whether the SG is created in default or specific VPC.The physical ID of the VPC.A description for the security group.The name of the security group.The outbound rules associated with the security group.The inbound rules associated with the security group.getTags()
Tag Manager which manages the tags for this resource.Any tags assigned to the security group.getVpcId()
The ID of the VPC for the security group.void
inspect
(TreeInspector inspector) Examines the CloudFormation resource and discloses attributes.renderProperties
(Map<String, Object> props) void
setGroupDescription
(String value) A description for the security group.void
setGroupName
(String value) The name of the security group.void
setSecurityGroupEgress
(List<Object> value) The outbound rules associated with the security group.void
The outbound rules associated with the security group.void
setSecurityGroupIngress
(List<Object> value) The inbound rules associated with the security group.void
The inbound rules associated with the security group.void
setTagsRaw
(List<CfnTag> value) Any tags assigned to the security group.void
The ID of the VPC for the security group.Methods inherited from class software.amazon.awscdk.CfnResource
addDeletionOverride, addDependency, addDependsOn, addMetadata, addOverride, addPropertyDeletionOverride, addPropertyOverride, applyRemovalPolicy, applyRemovalPolicy, applyRemovalPolicy, getAtt, getAtt, getCfnOptions, getCfnResourceType, getMetadata, getUpdatedProperites, getUpdatedProperties, isCfnResource, obtainDependencies, obtainResourceDependencies, removeDependency, replaceDependency, shouldSynthesize, toString, validateProperties
Methods inherited from class software.amazon.awscdk.CfnRefElement
getRef
Methods inherited from class software.amazon.awscdk.CfnElement
getCreationStack, getLogicalId, getStack, isCfnElement, overrideLogicalId
Methods inherited from class software.constructs.Construct
getNode, isConstruct
Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Field Details
-
CFN_RESOURCE_TYPE_NAME
The CloudFormation resource type name for this resource class.
-
-
Constructor Details
-
CfnSecurityGroup
protected CfnSecurityGroup(software.amazon.jsii.JsiiObjectRef objRef) -
CfnSecurityGroup
protected CfnSecurityGroup(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
CfnSecurityGroup
@Stability(Stable) public CfnSecurityGroup(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull CfnSecurityGroupProps props) - Parameters:
scope
- Scope in which this resource is defined. This parameter is required.id
- Construct identifier for this resource (unique in its scope). This parameter is required.props
- Resource properties. This parameter is required.
-
-
Method Details
-
inspect
Examines the CloudFormation resource and discloses attributes.- Specified by:
inspect
in interfaceIInspectable
- Parameters:
inspector
- tree inspector to collect and process attributes. This parameter is required.
-
renderProperties
@Stability(Stable) @NotNull protected Map<String,Object> renderProperties(@NotNull Map<String, Object> props) - Overrides:
renderProperties
in classCfnResource
- Parameters:
props
- This parameter is required.
-
getAttrGroupId
The group ID of the specified security group, such assg-94b3a1f6
. -
getAttrId
The group name or group ID depending on whether the SG is created in default or specific VPC. -
getAttrVpcId
The physical ID of the VPC.You can obtain the physical ID by using a reference to an AWS::EC2::VPC , such as:
{ "Ref" : "myVPC" }
. -
getCfnProperties
- Overrides:
getCfnProperties
in classCfnResource
-
getTags
Tag Manager which manages the tags for this resource. -
getGroupDescription
A description for the security group. -
setGroupDescription
A description for the security group. -
getGroupName
The name of the security group. -
setGroupName
The name of the security group. -
getSecurityGroupEgress
The outbound rules associated with the security group. -
setSecurityGroupEgress
The outbound rules associated with the security group. -
setSecurityGroupEgress
The outbound rules associated with the security group. -
getSecurityGroupIngress
The inbound rules associated with the security group. -
setSecurityGroupIngress
The inbound rules associated with the security group. -
setSecurityGroupIngress
The inbound rules associated with the security group. -
getTagsRaw
Any tags assigned to the security group. -
setTagsRaw
Any tags assigned to the security group. -
getVpcId
The ID of the VPC for the security group. -
setVpcId
The ID of the VPC for the security group.
-