@Generated(value="jsii-pacmak/1.67.0 (build 2c027f5)", date="2022-09-19T20:26:38.290Z") @Stability(value=Stable) public class CfnSecurityGroup extends CfnResource implements IInspectable
Specifies a security group. To create a security group, use the VpcId property to specify the VPC for which to create the security group.
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();
| Modifier and Type | Class and Description |
|---|---|
static class |
CfnSecurityGroup.Builder
A fluent builder for
CfnSecurityGroup. |
static interface |
CfnSecurityGroup.EgressProperty
[EC2-VPC only] Adds the specified egress rules to a security group for use with a VPC.
|
static interface |
CfnSecurityGroup.IngressProperty
Adds an inbound rule to a security group.
|
software.amazon.jsii.JsiiObject.InitializationModeIInspectable.Jsii$Default, IInspectable.Jsii$Proxy| Modifier and Type | Field and Description |
|---|---|
static String |
CFN_RESOURCE_TYPE_NAME
The CloudFormation resource type name for this resource class.
|
| Modifier | Constructor and Description |
|---|---|
|
CfnSecurityGroup(software.constructs.Construct scope,
String id,
CfnSecurityGroupProps props)
Create a new `AWS::EC2::SecurityGroup`.
|
protected |
CfnSecurityGroup(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
CfnSecurityGroup(software.amazon.jsii.JsiiObjectRef objRef) |
| Modifier and Type | Method and Description |
|---|---|
String |
getAttrGroupId()
The group ID of the specified security group, such as `sg-94b3a1f6` .
|
String |
getAttrVpcId()
The physical ID of the VPC.
|
protected Map<String,Object> |
getCfnProperties() |
String |
getGroupDescription()
A description for the security group.
|
String |
getGroupName()
The name of the security group.
|
Object |
getSecurityGroupEgress()
[VPC only] The outbound rules associated with the security group.
|
Object |
getSecurityGroupIngress()
The inbound rules associated with the security group.
|
TagManager |
getTags()
Any tags assigned to the security group.
|
String |
getVpcId()
[VPC only] The ID of the VPC for the security group.
|
void |
inspect(TreeInspector inspector)
Examines the CloudFormation resource and discloses attributes.
|
protected Map<String,Object> |
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(IResolvable value)
[VPC only] The outbound rules associated with the security group.
|
void |
setSecurityGroupEgress(List<Object> value)
[VPC only] The outbound rules associated with the security group.
|
void |
setSecurityGroupIngress(IResolvable value)
The inbound rules associated with the security group.
|
void |
setSecurityGroupIngress(List<Object> value)
The inbound rules associated with the security group.
|
void |
setVpcId(String value)
[VPC only] The ID of the VPC for the security group.
|
addDeletionOverride, addDependsOn, addMetadata, addOverride, addPropertyDeletionOverride, addPropertyOverride, applyRemovalPolicy, applyRemovalPolicy, applyRemovalPolicy, getAtt, getCfnOptions, getCfnResourceType, getMetadata, getUpdatedProperites, getUpdatedProperties, isCfnResource, shouldSynthesize, toString, validatePropertiesgetRefgetCreationStack, getLogicalId, getStack, isCfnElement, overrideLogicalIdjsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet@Stability(value=Stable) public static final String CFN_RESOURCE_TYPE_NAME
protected CfnSecurityGroup(software.amazon.jsii.JsiiObjectRef objRef)
protected CfnSecurityGroup(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
@Stability(value=Stable)
public CfnSecurityGroup(@NotNull
software.constructs.Construct scope,
@NotNull
String id,
@NotNull
CfnSecurityGroupProps props)
scope - - scope in which this resource is defined. This parameter is required.id - - scoped id of the resource. This parameter is required.props - - resource properties. This parameter is required.@Stability(value=Stable)
public void inspect(@NotNull
TreeInspector inspector)
inspect in interface IInspectableinspector - - tree inspector to collect and process attributes. This parameter is required.@Stability(value=Stable) @NotNull protected Map<String,Object> renderProperties(@NotNull Map<String,Object> props)
renderProperties in class CfnResourceprops - This parameter is required.@Stability(value=Stable) @NotNull public String getAttrGroupId()
@Stability(value=Stable) @NotNull public String getAttrVpcId()
You can obtain the physical ID by using a reference to an AWS::EC2::VPC , such as: { "Ref" : "myVPC" } .
@Stability(value=Stable) @NotNull protected Map<String,Object> getCfnProperties()
getCfnProperties in class CfnResource@Stability(value=Stable) @NotNull public TagManager getTags()
@Stability(value=Stable) @NotNull public String getGroupDescription()
Constraints: Up to 255 characters in length
Constraints for EC2-Classic: ASCII characters
Constraints for EC2-VPC: a-z, A-Z, 0-9, spaces, and ._-:/()#,@[]+=&;{}!$*
@Stability(value=Stable)
public void setGroupDescription(@NotNull
String value)
Constraints: Up to 255 characters in length
Constraints for EC2-Classic: ASCII characters
Constraints for EC2-VPC: a-z, A-Z, 0-9, spaces, and ._-:/()#,@[]+=&;{}!$*
@Stability(value=Stable) @Nullable public String getGroupName()
Constraints: Up to 255 characters in length. Cannot start with sg- .
Constraints for EC2-Classic: ASCII characters
Constraints for EC2-VPC: a-z, A-Z, 0-9, spaces, and ._-:/()#,@[]+=&;{}!$*
@Stability(value=Stable)
public void setGroupName(@Nullable
String value)
Constraints: Up to 255 characters in length. Cannot start with sg- .
Constraints for EC2-Classic: ASCII characters
Constraints for EC2-VPC: a-z, A-Z, 0-9, spaces, and ._-:/()#,@[]+=&;{}!$*
@Stability(value=Stable) @Nullable public Object getSecurityGroupEgress()
There is a short interruption during which you cannot connect to the security group.
@Stability(value=Stable)
public void setSecurityGroupEgress(@Nullable
IResolvable value)
There is a short interruption during which you cannot connect to the security group.
@Stability(value=Stable)
public void setSecurityGroupEgress(@Nullable
List<Object> value)
There is a short interruption during which you cannot connect to the security group.
@Stability(value=Stable) @Nullable public Object getSecurityGroupIngress()
There is a short interruption during which you cannot connect to the security group.
@Stability(value=Stable)
public void setSecurityGroupIngress(@Nullable
IResolvable value)
There is a short interruption during which you cannot connect to the security group.
@Stability(value=Stable)
public void setSecurityGroupIngress(@Nullable
List<Object> value)
There is a short interruption during which you cannot connect to the security group.
@Stability(value=Stable) @Nullable public String getVpcId()
@Stability(value=Stable)
public void setVpcId(@Nullable
String value)
Copyright © 2022. All rights reserved.