Class CfnSecurityGroup
Specifies a security group.
Inherited Members
Namespace: Amazon.CDK.AWS.EC2
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class CfnSecurityGroup : CfnResource, IInspectable, ITaggable
Syntax (vb)
Public Class CfnSecurityGroup
Inherits CfnResource
Implements IInspectable, ITaggable
Remarks
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.
See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-securitygroup.html
CloudformationResource: AWS::EC2::SecurityGroup
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(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 |
CfnSecurityGroup(Construct, String, ICfnSecurityGroupProps) |
Properties
AttrGroupId | The ID of the security group, such as |
AttrId | The group name or group ID depending on whether the SG is created in default or specific VPC. |
AttrVpcId | The ID of the VPC, such as |
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 | Tag Manager which manages the tags for this resource. |
TagsRaw | 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(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
CfnSecurityGroup(Construct, String, ICfnSecurityGroupProps)
public CfnSecurityGroup(Construct scope, string id, ICfnSecurityGroupProps props)
Parameters
- scope Constructs.Construct
Scope in which this resource is defined.
- id System.String
Construct identifier for this resource (unique in its scope).
- props ICfnSecurityGroupProps
Resource properties.
Properties
AttrGroupId
The ID of the security group, such as sg-94b3a1f6
.
public virtual string AttrGroupId { get; }
Property Value
System.String
Remarks
CloudformationAttribute: GroupId
AttrId
The group name or group ID depending on whether the SG is created in default or specific VPC.
public virtual string AttrId { get; }
Property Value
System.String
Remarks
CloudformationAttribute: Id
AttrVpcId
The ID of the VPC, such as vpc-0669f8f9
.
public virtual string AttrVpcId { get; }
Property Value
System.String
Remarks
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
GroupName
The name of the security group.
public virtual string GroupName { get; set; }
Property Value
System.String
SecurityGroupEgress
The outbound rules associated with the security group.
public virtual object SecurityGroupEgress { get; set; }
Property Value
System.Object
SecurityGroupIngress
The inbound rules associated with the security group.
public virtual object SecurityGroupIngress { get; set; }
Property Value
System.Object
Tags
Tag Manager which manages the tags for this resource.
public virtual TagManager Tags { get; }
Property Value
TagsRaw
Any tags assigned to the security group.
public virtual ICfnTag[] TagsRaw { get; set; }
Property Value
ICfnTag[]
VpcId
The ID of the VPC for the security group.
public virtual string VpcId { get; set; }
Property Value
System.String
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>