import { SecurityGroup } from '@pepperize/cdk-security-group'
new SecurityGroup(scope: Construct, id: string, props: SecurityGroupProps)
Name | Type | Description |
---|---|---|
scope |
constructs.Construct |
No description. |
id |
string |
No description. |
props |
SecurityGroupProps |
No description. |
- Type: constructs.Construct
- Type: string
- Type: SecurityGroupProps
Name | Description |
---|---|
toString |
Returns a string representation of this construct. |
applyRemovalPolicy |
Apply the given removal policy to this resource. |
addEgressRule |
Add an egress rule for the current security group. |
addIngressRule |
Add an ingress rule for the current security group. |
toEgressRuleConfig |
Produce the egress rule JSON for the given connection. |
toIngressRuleConfig |
Produce the ingress rule JSON for the given connection. |
public toString(): string
Returns a string representation of this construct.
public applyRemovalPolicy(policy: RemovalPolicy): void
Apply the given removal policy to this resource.
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.
The resource can be deleted (RemovalPolicy.DESTROY
), or left in your AWS
account for data recovery and cleanup later (RemovalPolicy.RETAIN
).
- Type: aws-cdk-lib.RemovalPolicy
public addEgressRule(peer: IPeer, connection: Port, description?: string, remoteRule?: boolean): void
Add an egress rule for the current security group.
remoteRule
controls where the Rule object is created if the peer is also a
securityGroup and they are in different stack. If false (default) the
rule object is created under the current SecurityGroup object. If true and the
peer is also a SecurityGroup, the rule object is created under the remote
SecurityGroup object.
- Type: aws-cdk-lib.aws_ec2.IPeer
- Type: aws-cdk-lib.aws_ec2.Port
- Type: string
- Type: boolean
public addIngressRule(peer: IPeer, connection: Port, description?: string, remoteRule?: boolean): void
Add an ingress rule for the current security group.
remoteRule
controls where the Rule object is created if the peer is also a
securityGroup and they are in different stack. If false (default) the
rule object is created under the current SecurityGroup object. If true and the
peer is also a SecurityGroup, the rule object is created under the remote
SecurityGroup object.
- Type: aws-cdk-lib.aws_ec2.IPeer
- Type: aws-cdk-lib.aws_ec2.Port
- Type: string
- Type: boolean
public toEgressRuleConfig(): any
Produce the egress rule JSON for the given connection.
public toIngressRuleConfig(): any
Produce the ingress rule JSON for the given connection.
Name | Description |
---|---|
isConstruct |
Checks if x is a construct. |
isResource |
Check whether the given construct is a Resource. |
fromLookupById |
Look up a security group by id. |
fromLookupByName |
Look up a security group by name. |
fromSecurityGroupId |
Import an existing security group into this app. |
isSecurityGroup |
Return whether the indicated object is a security group. |
import { SecurityGroup } from '@pepperize/cdk-security-group'
SecurityGroup.isConstruct(x: any)
Checks if x
is a construct.
- Type: any
Any object.
import { SecurityGroup } from '@pepperize/cdk-security-group'
SecurityGroup.isResource(construct: IConstruct)
Check whether the given construct is a Resource.
- Type: constructs.IConstruct
import { SecurityGroup } from '@pepperize/cdk-security-group'
SecurityGroup.fromLookupById(scope: Construct, id: string, securityGroupId: string)
Look up a security group by id.
- Type: constructs.Construct
- Type: string
- Type: string
import { SecurityGroup } from '@pepperize/cdk-security-group'
SecurityGroup.fromLookupByName(scope: Construct, id: string, securityGroupName: string, vpc: IVpc)
Look up a security group by name.
- Type: constructs.Construct
- Type: string
- Type: string
- Type: aws-cdk-lib.aws_ec2.IVpc
import { SecurityGroup } from '@pepperize/cdk-security-group'
SecurityGroup.fromSecurityGroupId(scope: Construct, id: string, securityGroupId: string, options?: SecurityGroupImportOptions)
Import an existing security group into this app.
This method will assume that the Security Group has a rule in it which allows all outbound traffic, and so will not add egress rules to the imported Security Group (only ingress rules).
If your existing Security Group needs to have egress rules added, pass the
allowAllOutbound: false
option on import.
- Type: constructs.Construct
- Type: string
- Type: string
- Type: aws-cdk-lib.aws_ec2.SecurityGroupImportOptions
import { SecurityGroup } from '@pepperize/cdk-security-group'
SecurityGroup.isSecurityGroup(x: any)
Return whether the indicated object is a security group.
- Type: any
Name | Type | Description |
---|---|---|
node |
constructs.Node |
The tree node. |
env |
aws-cdk-lib.ResourceEnvironment |
The environment this resource belongs to. |
stack |
aws-cdk-lib.Stack |
The stack in which this resource is defined. |
allowAllOutbound |
boolean |
Whether the SecurityGroup has been configured to allow all outbound traffic. |
canInlineRule |
boolean |
Whether the rule can be inlined into a SecurityGroup or not. |
connections |
aws-cdk-lib.aws_ec2.Connections |
The network connections associated with this resource. |
securityGroupId |
string |
The ID of the security group. |
securityGroupVpcId |
string |
The VPC ID this security group is part of. |
uniqueId |
string |
A unique identifier for this connection peer. |
defaultPort |
aws-cdk-lib.aws_ec2.Port |
No description. |
securityGroupName |
string |
An attribute that represents the security group name. |
public readonly node: Node;
- Type: constructs.Node
The tree node.
public readonly env: ResourceEnvironment;
- Type: aws-cdk-lib.ResourceEnvironment
The environment this resource belongs to.
For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.
public readonly stack: Stack;
- Type: aws-cdk-lib.Stack
The stack in which this resource is defined.
public readonly allowAllOutbound: boolean;
- Type: boolean
Whether the SecurityGroup has been configured to allow all outbound traffic.
public readonly canInlineRule: boolean;
- Type: boolean
Whether the rule can be inlined into a SecurityGroup or not.
public readonly connections: Connections;
- Type: aws-cdk-lib.aws_ec2.Connections
The network connections associated with this resource.
public readonly securityGroupId: string;
- Type: string
The ID of the security group.
public readonly securityGroupVpcId: string;
- Type: string
The VPC ID this security group is part of.
public readonly uniqueId: string;
- Type: string
A unique identifier for this connection peer.
public readonly defaultPort: Port;
- Type: aws-cdk-lib.aws_ec2.Port
public readonly securityGroupName: string;
- Type: string
An attribute that represents the security group name.
import { SecurityGroupProps } from '@pepperize/cdk-security-group'
const securityGroupProps: SecurityGroupProps = { ... }
Name | Type | Description |
---|---|---|
vpc |
aws-cdk-lib.aws_ec2.IVpc |
The VPC in which to create the security group. |
allowAllOutbound |
boolean |
Whether to allow all outbound traffic by default. |
description |
string |
A description of the security group. |
disableInlineRules |
boolean |
Whether to disable inline ingress and egress rule optimization. |
securityGroupName |
string |
The name of the security group. |
public readonly vpc: IVpc;
- Type: aws-cdk-lib.aws_ec2.IVpc
The VPC in which to create the security group.
public readonly allowAllOutbound: boolean;
- Type: boolean
- Default: true
Whether to allow all outbound traffic by default.
If this is set to true, there will only be a single egress rule which allows all outbound traffic. If this is set to false, no outbound traffic will be allowed by default and all egress traffic must be explicitly authorized.
public readonly description: string;
- Type: string
- Default: The default name will be the construct's CDK path.
A description of the security group.
public readonly disableInlineRules: boolean;
- Type: boolean
- Default: false
Whether to disable inline ingress and egress rule optimization.
If this is set to true, ingress and egress rules will not be declared under the SecurityGroup in cloudformation, but will be separate elements.
Inlining rules is an optimization for producing smaller stack templates. Sometimes this is not desirable, for example when security group access is managed via tags.
The default value can be overriden globally by setting the context variable '@aws-cdk/aws-ec2.securityGroupDisableInlineRules'.
public readonly securityGroupName: string;
- Type: string
- Default: If you don't specify a GroupName, AWS CloudFormation generates a unique physical ID and uses that ID for the group name.
The name of the security group.
For valid values, see the GroupName parameter of the CreateSecurityGroup action in the Amazon EC2 API Reference.
It is not recommended to use an explicit group name.