class VpnConnection (construct)
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.EC2.VpnConnection |
Java | software.amazon.awscdk.services.ec2.VpnConnection |
Python | aws_cdk.aws_ec2.VpnConnection |
TypeScript (source) | @aws-cdk/aws-ec2 » VpnConnection |
Implements
IConstruct
, IConstruct
, IDependable
, IResource
, IVpn
Define a VPN Connection.
Example
// Across all tunnels in the account/region
const allDataOut = ec2.VpnConnection.metricAllTunnelDataOut();
// For a specific vpn connection
const vpnConnection = vpc.addVpnConnection('Dynamic', {
ip: '1.2.3.4'
});
const state = vpnConnection.metricTunnelState();
Initializer
new VpnConnection(scope: Construct, id: string, props: VpnConnectionProps)
Parameters
- scope
Construct
- id
string
- props
Vpn
Connection Props
Construct Props
Name | Type | Description |
---|---|---|
ip | string | The ip address of the customer gateway. |
vpc | IVpc | The VPC to connect to. |
asn? | number | The ASN of the customer gateway. |
static | string[] | The static routes to be routed from the VPN gateway to the customer gateway. |
tunnel | Vpn [] | The tunnel options for the VPN connection. |
ip
Type:
string
The ip address of the customer gateway.
vpc
Type:
IVpc
The VPC to connect to.
asn?
Type:
number
(optional, default: 65000)
The ASN of the customer gateway.
staticRoutes?
Type:
string[]
(optional, default: Dynamic routing (BGP))
The static routes to be routed from the VPN gateway to the customer gateway.
tunnelOptions?
Type:
Vpn
[]
(optional, default: Amazon generated tunnel options)
The tunnel options for the VPN connection.
At most two elements (one per tunnel). Duplicates not allowed.
Properties
Name | Type | Description |
---|---|---|
customer | number | The ASN of the customer gateway. |
customer | string | The id of the customer gateway. |
customer | string | The ip address of the customer gateway. |
env | Resource | The environment this resource belongs to. |
node | Construct | The construct tree node associated with this construct. |
stack | Stack | The stack in which this resource is defined. |
vpn | string | The id of the VPN connection. |
customerGatewayAsn
Type:
number
The ASN of the customer gateway.
customerGatewayId
Type:
string
The id of the customer gateway.
customerGatewayIp
Type:
string
The ip address of the customer gateway.
env
Type:
Resource
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.
node
Type:
Construct
The construct tree node associated with this construct.
stack
Type:
Stack
The stack in which this resource is defined.
vpnId
Type:
string
The id of the VPN connection.
Methods
Name | Description |
---|---|
apply | Apply the given removal policy to this resource. |
metric(metricName, props?) | Return the given named metric for this VPNConnection. |
metric | The bytes received through the VPN tunnel. |
metric | The bytes sent through the VPN tunnel. |
metric | The state of the tunnel. 0 indicates DOWN and 1 indicates UP. |
to | Returns a string representation of this construct. |
static from | Import a VPN connection by supplying all attributes directly. |
static metric | Return the given named metric for all VPN connections in the account/region. |
static metric | Metric for the tunnel data in of all VPN connections in the account/region. |
static metric | Metric for the tunnel data out of all VPN connections. |
static metric | Metric for the tunnel state of all VPN connections in the account/region. |
applyRemovalPolicy(policy)
public applyRemovalPolicy(policy: RemovalPolicy): void
Parameters
- policy
Removal
Policy
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
).
metric(metricName, props?)
public metric(metricName: string, props?: MetricOptions): Metric
Parameters
- metricName
string
- props
Metric
Options
Returns
Return the given named metric for this VPNConnection.
metricTunnelDataIn(props?)
public metricTunnelDataIn(props?: MetricOptions): Metric
Parameters
- props
Metric
Options
Returns
The bytes received through the VPN tunnel.
Sum over 5 minutes
metricTunnelDataOut(props?)
public metricTunnelDataOut(props?: MetricOptions): Metric
Parameters
- props
Metric
Options
Returns
The bytes sent through the VPN tunnel.
Sum over 5 minutes
metricTunnelState(props?)
public metricTunnelState(props?: MetricOptions): Metric
Parameters
- props
Metric
Options
Returns
The state of the tunnel. 0 indicates DOWN and 1 indicates UP.
Average over 5 minutes
toString()
public toString(): string
Returns
string
Returns a string representation of this construct.
static fromVpnConnectionAttributes(scope, id, attrs)
public static fromVpnConnectionAttributes(scope: Construct, id: string, attrs: VpnConnectionAttributes): IVpnConnection
Parameters
- scope
Construct
- id
string
- attrs
Vpn
Connection Attributes
Returns
Import a VPN connection by supplying all attributes directly.
static metricAll(metricName, props?)
public static metricAll(metricName: string, props?: MetricOptions): Metric
Parameters
- metricName
string
- props
Metric
Options
Returns
Return the given named metric for all VPN connections in the account/region.
static metricAllTunnelDataIn(props?)
public static metricAllTunnelDataIn(props?: MetricOptions): Metric
Parameters
- props
Metric
Options
Returns
Metric for the tunnel data in of all VPN connections in the account/region.
static metricAllTunnelDataOut(props?)
public static metricAllTunnelDataOut(props?: MetricOptions): Metric
Parameters
- props
Metric
Options
Returns
Metric for the tunnel data out of all VPN connections.
static metricAllTunnelState(props?)
public static metricAllTunnelState(props?: MetricOptions): Metric
Parameters
- props
Metric
Options
Returns
Metric for the tunnel state of all VPN connections in the account/region.