Class CfnSecurityGroup
A CloudFormation AWS::EC2::SecurityGroup
.
Inherited Members
Namespace: Amazon.CDK.AWS.EC2
Assembly: Amazon.CDK.AWS.EC2.dll
Syntax (csharp)
public class CfnSecurityGroup : CfnResource, IConstruct, IDependable, IInspectable
Syntax (vb)
Public Class CfnSecurityGroup
Inherits CfnResource
Implements IConstruct, IDependable, IInspectable
Remarks
Specifies a security group. 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. If you later remove your egress rules, we restore the default 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.
CloudformationResource: AWS::EC2::SecurityGroup
Link: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-security-group.html
ExampleMetadata: fixture=_generated
Examples
// 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 cfnSecurityGroup = new CfnSecurityGroup(this, "MyCfnSecurityGroup", 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"
});
Synopsis
Constructors
CfnSecurityGroup(Construct, String, ICfnSecurityGroupProps) | Create a new |
CfnSecurityGroup(ByRefValue) | Used by jsii to construct an instance of this class from a Javascript-owned object reference |
CfnSecurityGroup(DeputyBase.DeputyProps) | Used by jsii to construct an instance of this class from DeputyProps |
Properties
AttrGroupId | The group ID of the specified security group, such as |
AttrVpcId | The physical ID of the VPC. |
CFN_RESOURCE_TYPE_NAME | The CloudFormation resource type name for this resource class. |
CfnProperties | |
GroupDescription | A description for the security group. |
GroupName | The name of the security group. |
SecurityGroupEgress | The outbound rules associated with the security group. |
SecurityGroupIngress | The inbound rules associated with the security group. |
Tags | Any tags assigned to the security group. |
VpcId | The ID of the VPC for the security group. |
Methods
Inspect(TreeInspector) | Examines the CloudFormation resource and discloses attributes. |
RenderProperties(IDictionary<String, Object>) |
Constructors
CfnSecurityGroup(Construct, String, ICfnSecurityGroupProps)
Create a new AWS::EC2::SecurityGroup
.
public CfnSecurityGroup(Construct scope, string id, ICfnSecurityGroupProps props)
Parameters
- scope Construct
- scope in which this resource is defined.
- id System.String
- scoped id of the resource.
- props ICfnSecurityGroupProps
- resource properties.
CfnSecurityGroup(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected CfnSecurityGroup(ByRefValue reference)
Parameters
- reference Amazon.JSII.Runtime.Deputy.ByRefValue
The Javascript-owned object reference
CfnSecurityGroup(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected CfnSecurityGroup(DeputyBase.DeputyProps props)
Parameters
- props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps
The deputy props
Properties
AttrGroupId
The group ID of the specified security group, such as sg-94b3a1f6
.
public virtual string AttrGroupId { get; }
Property Value
System.String
Remarks
CloudformationAttribute: GroupId
AttrVpcId
The physical ID of the VPC.
public virtual string AttrVpcId { get; }
Property Value
System.String
Remarks
You can obtain the physical ID by using a reference to an AWS::EC2::VPC , such as: { "Ref" : "myVPC" }
.
CloudformationAttribute: VpcId
CFN_RESOURCE_TYPE_NAME
The CloudFormation resource type name for this resource class.
public static string CFN_RESOURCE_TYPE_NAME { get; }
Property Value
System.String
CfnProperties
protected override IDictionary<string, object> CfnProperties { get; }
Property Value
System.Collections.Generic.IDictionary<System.String, System.Object>
Overrides
GroupDescription
A description for the security group.
public virtual string GroupDescription { get; set; }
Property Value
System.String
Remarks
Constraints: Up to 255 characters in length
Valid characters: a-z, A-Z, 0-9, spaces, and ._-:/()#,@[]+=&;{}!$*
GroupName
The name of the security group.
public virtual string GroupName { get; set; }
Property Value
System.String
Remarks
Constraints: Up to 255 characters in length. Cannot start with sg-
.
Valid characters: a-z, A-Z, 0-9, spaces, and ._-:/()#,@[]+=&;{}!$*
SecurityGroupEgress
The outbound rules associated with the security group.
public virtual object SecurityGroupEgress { get; set; }
Property Value
System.Object
Remarks
There is a short interruption during which you cannot connect to the security group.
SecurityGroupIngress
The inbound rules associated with the security group.
public virtual object SecurityGroupIngress { get; set; }
Property Value
System.Object
Remarks
There is a short interruption during which you cannot connect to the security group.
Tags
Any tags assigned to the security group.
public virtual TagManager Tags { get; }
Property Value
Remarks
VpcId
The ID of the VPC for the security group.
public virtual string VpcId { get; set; }
Property Value
System.String
Remarks
Methods
Inspect(TreeInspector)
Examines the CloudFormation resource and discloses attributes.
public virtual void Inspect(TreeInspector inspector)
Parameters
- inspector TreeInspector
- tree inspector to collect and process attributes.
RenderProperties(IDictionary<String, Object>)
protected override IDictionary<string, object> RenderProperties(IDictionary<string, object> props)
Parameters
- props System.Collections.Generic.IDictionary<System.String, System.Object>
Returns
System.Collections.Generic.IDictionary<System.String, System.Object>