CfnNetworkInterface
- class aws_cdk.aws_ec2.CfnNetworkInterface(scope, id, *, subnet_id, connection_tracking_specification=None, description=None, enable_primary_ipv6=None, group_set=None, interface_type=None, ipv4_prefix_count=None, ipv4_prefixes=None, ipv6_address_count=None, ipv6_addresses=None, ipv6_prefix_count=None, ipv6_prefixes=None, private_ip_address=None, private_ip_addresses=None, secondary_private_ip_address_count=None, source_dest_check=None, tags=None)
Bases:
CfnResource
Describes a network interface in an Amazon EC2 instance for AWS CloudFormation .
- See:
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-networkinterface.html
- CloudformationResource:
AWS::EC2::NetworkInterface
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk import aws_ec2 as ec2 cfn_network_interface = ec2.CfnNetworkInterface(self, "MyCfnNetworkInterface", subnet_id="subnetId", # the properties below are optional connection_tracking_specification=ec2.CfnNetworkInterface.ConnectionTrackingSpecificationProperty( tcp_established_timeout=123, udp_stream_timeout=123, udp_timeout=123 ), description="description", enable_primary_ipv6=False, group_set=["groupSet"], interface_type="interfaceType", ipv4_prefix_count=123, ipv4_prefixes=[ec2.CfnNetworkInterface.Ipv4PrefixSpecificationProperty( ipv4_prefix="ipv4Prefix" )], ipv6_address_count=123, ipv6_addresses=[ec2.CfnNetworkInterface.InstanceIpv6AddressProperty( ipv6_address="ipv6Address" )], ipv6_prefix_count=123, ipv6_prefixes=[ec2.CfnNetworkInterface.Ipv6PrefixSpecificationProperty( ipv6_prefix="ipv6Prefix" )], private_ip_address="privateIpAddress", private_ip_addresses=[ec2.CfnNetworkInterface.PrivateIpAddressSpecificationProperty( primary=False, private_ip_address="privateIpAddress" )], secondary_private_ip_address_count=123, source_dest_check=False, tags=[CfnTag( key="key", value="value" )] )
- Parameters:
scope (
Construct
) – Scope in which this resource is defined.id (
str
) – Construct identifier for this resource (unique in its scope).subnet_id (
str
) – The ID of the subnet to associate with the network interface.connection_tracking_specification (
Union
[IResolvable
,ConnectionTrackingSpecificationProperty
,Dict
[str
,Any
],None
]) – A connection tracking specification for the network interface.description (
Optional
[str
]) – A description for the network interface.enable_primary_ipv6 (
Union
[bool
,IResolvable
,None
]) – If you’re modifying a network interface in a dual-stack or IPv6-only subnet, you have the option to assign a primary IPv6 IP address. A primary IPv6 address is an IPv6 GUA address associated with an ENI that you have enabled to use a primary IPv6 address. Use this option if the instance that this ENI will be attached to relies on its IPv6 address not changing. AWS will automatically assign an IPv6 address associated with the ENI attached to your instance to be the primary IPv6 address. Once you enable an IPv6 GUA address to be a primary IPv6, you cannot disable it. When you enable an IPv6 GUA address to be a primary IPv6, the first IPv6 GUA will be made the primary IPv6 address until the instance is terminated or the network interface is detached. If you have multiple IPv6 addresses associated with an ENI attached to your instance and you enable a primary IPv6 address, the first IPv6 GUA address associated with the ENI becomes the primary IPv6 address.group_set (
Optional
[Sequence
[str
]]) – The IDs of the security groups associated with this network interface.interface_type (
Optional
[str
]) – The type of network interface. The default isinterface
. The supported values areefa
andtrunk
.ipv4_prefix_count (
Union
[int
,float
,None
]) – The number of IPv4 prefixes to be automatically assigned to the network interface. When creating a network interface, you can’t specify a count of IPv4 prefixes if you’ve specified one of the following: specific IPv4 prefixes, specific private IPv4 addresses, or a count of private IPv4 addresses.ipv4_prefixes (
Union
[IResolvable
,Sequence
[Union
[IResolvable
,Ipv4PrefixSpecificationProperty
,Dict
[str
,Any
]]],None
]) – The IPv4 delegated prefixes that are assigned to the network interface. When creating a network interface, you can’t specify IPv4 prefixes if you’ve specified one of the following: a count of IPv4 prefixes, specific private IPv4 addresses, or a count of private IPv4 addresses.ipv6_address_count (
Union
[int
,float
,None
]) – The number of IPv6 addresses to assign to the network interface. Amazon EC2 automatically selects the IPv6 addresses from the subnet range. To specify specific IPv6 addresses, use theIpv6Addresses
property and don’t specify this property. When creating a network interface, you can’t specify a count of IPv6 addresses if you’ve specified one of the following: specific IPv6 addresses, specific IPv6 prefixes, or a count of IPv6 prefixes.ipv6_addresses (
Union
[IResolvable
,Sequence
[Union
[IResolvable
,InstanceIpv6AddressProperty
,Dict
[str
,Any
]]],None
]) – The IPv6 addresses from the IPv6 CIDR block range of your subnet to assign to the network interface. If you’re specifying a number of IPv6 addresses, use theIpv6AddressCount
property and don’t specify this property. When creating a network interface, you can’t specify IPv6 addresses if you’ve specified one of the following: a count of IPv6 addresses, specific IPv6 prefixes, or a count of IPv6 prefixes.ipv6_prefix_count (
Union
[int
,float
,None
]) – The number of IPv6 prefixes to be automatically assigned to the network interface. When creating a network interface, you can’t specify a count of IPv6 prefixes if you’ve specified one of the following: specific IPv6 prefixes, specific IPv6 addresses, or a count of IPv6 addresses.ipv6_prefixes (
Union
[IResolvable
,Sequence
[Union
[IResolvable
,Ipv6PrefixSpecificationProperty
,Dict
[str
,Any
]]],None
]) – The IPv6 delegated prefixes that are assigned to the network interface. When creating a network interface, you can’t specify IPv6 prefixes if you’ve specified one of the following: a count of IPv6 prefixes, specific IPv6 addresses, or a count of IPv6 addresses.private_ip_address (
Optional
[str
]) – The private IPv4 address to assign to the network interface as the primary private IP address. If you want to specify multiple private IP addresses, use thePrivateIpAddresses
property.private_ip_addresses (
Union
[IResolvable
,Sequence
[Union
[IResolvable
,PrivateIpAddressSpecificationProperty
,Dict
[str
,Any
]]],None
]) – The private IPv4 addresses to assign to the network interface. You can specify a primary private IP address by setting the value of thePrimary
property totrue
in thePrivateIpAddressSpecification
property. If you want EC2 to automatically assign private IP addresses, use theSecondaryPrivateIpAddressCount
property and do not specify this property. When creating a network interface, you can’t specify private IPv4 addresses if you’ve specified one of the following: a count of private IPv4 addresses, specific IPv4 prefixes, or a count of IPv4 prefixes.secondary_private_ip_address_count (
Union
[int
,float
,None
]) – The number of secondary private IPv4 addresses to assign to a network interface. When you specify a number of secondary IPv4 addresses, Amazon EC2 selects these IP addresses within the subnet’s IPv4 CIDR range. You can’t specify this option and specify more than one private IP address usingprivateIpAddresses
. When creating a Network Interface, you can’t specify a count of private IPv4 addresses if you’ve specified one of the following: specific private IPv4 addresses, specific IPv4 prefixes, or a count of IPv4 prefixes.source_dest_check (
Union
[bool
,IResolvable
,None
]) – Enable or disable source/destination checks, which ensure that the instance is either the source or the destination of any traffic that it receives. If the value istrue
, source/destination checks are enabled; otherwise, they are disabled. The default value istrue
. You must disable source/destination checks if the instance runs services such as network address translation, routing, or firewalls.tags (
Optional
[Sequence
[Union
[CfnTag
,Dict
[str
,Any
]]]]) – The tags to apply to the network interface.
Methods
- add_deletion_override(path)
Syntactic sugar for
addOverride(path, undefined)
.- Parameters:
path (
str
) – The path of the value to delete.- Return type:
None
- add_dependency(target)
Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned.
This can be used for resources across stacks (or nested stack) boundaries and the dependency will automatically be transferred to the relevant scope.
- Parameters:
target (
CfnResource
) –- Return type:
None
- add_depends_on(target)
(deprecated) Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned.
- Parameters:
target (
CfnResource
) –- Deprecated:
use addDependency
- Stability:
deprecated
- Return type:
None
- add_metadata(key, value)
Add a value to the CloudFormation Resource Metadata.
- Parameters:
key (
str
) –value (
Any
) –
- See:
- Return type:
None
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/metadata-section-structure.html
Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.
- add_override(path, value)
Adds an override to the synthesized CloudFormation resource.
To add a property override, either use
addPropertyOverride
or prefixpath
with “Properties.” (i.e.Properties.TopicName
).If the override is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.
To include a literal
.
in the property name, prefix with a\
. In most programming languages you will need to write this as"\\."
because the\
itself will need to be escaped.For example:
cfn_resource.add_override("Properties.GlobalSecondaryIndexes.0.Projection.NonKeyAttributes", ["myattribute"]) cfn_resource.add_override("Properties.GlobalSecondaryIndexes.1.ProjectionType", "INCLUDE")
would add the overrides Example:
"Properties": { "GlobalSecondaryIndexes": [ { "Projection": { "NonKeyAttributes": [ "myattribute" ] ... } ... }, { "ProjectionType": "INCLUDE" ... }, ] ... }
The
value
argument toaddOverride
will not be processed or translated in any way. Pass raw JSON values in here with the correct capitalization for CloudFormation. If you pass CDK classes or structs, they will be rendered with lowercased key names, and CloudFormation will reject the template.- Parameters:
path (
str
) –The path of the property, you can use dot notation to override values in complex types. Any intermediate keys will be created as needed.
value (
Any
) –The value. Could be primitive or complex.
- Return type:
None
- add_property_deletion_override(property_path)
Adds an override that deletes the value of a property from the resource definition.
- Parameters:
property_path (
str
) – The path to the property.- Return type:
None
- add_property_override(property_path, value)
Adds an override to a resource property.
Syntactic sugar for
addOverride("Properties.<...>", value)
.- Parameters:
property_path (
str
) – The path of the property.value (
Any
) – The value.
- Return type:
None
- apply_removal_policy(policy=None, *, apply_to_update_replace_policy=None, default=None)
Sets the deletion policy of the resource based on the removal policy specified.
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
). In some cases, a snapshot can be taken of the resource prior to deletion (RemovalPolicy.SNAPSHOT
). A list of resources that support this policy can be found in the following link:- Parameters:
policy (
Optional
[RemovalPolicy
]) –apply_to_update_replace_policy (
Optional
[bool
]) – Apply the same deletion policy to the resource’s “UpdateReplacePolicy”. Default: truedefault (
Optional
[RemovalPolicy
]) – The default policy to apply in case the removal policy is not defined. Default: - Default value is resource specific. To determine the default value for a resource, please consult that specific resource’s documentation.
- See:
- Return type:
None
- get_att(attribute_name, type_hint=None)
Returns a token for an runtime attribute of this resource.
Ideally, use generated attribute accessors (e.g.
resource.arn
), but this can be used for future compatibility in case there is no generated attribute.- Parameters:
attribute_name (
str
) – The name of the attribute.type_hint (
Optional
[ResolutionTypeHint
]) –
- Return type:
- get_metadata(key)
Retrieve a value value from the CloudFormation Resource Metadata.
- Parameters:
key (
str
) –- See:
- Return type:
Any
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/metadata-section-structure.html
Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.
- inspect(inspector)
Examines the CloudFormation resource and discloses attributes.
- Parameters:
inspector (
TreeInspector
) – tree inspector to collect and process attributes.- Return type:
None
- obtain_dependencies()
Retrieves an array of resources this resource depends on.
This assembles dependencies on resources across stacks (including nested stacks) automatically.
- Return type:
List
[Union
[Stack
,CfnResource
]]
- obtain_resource_dependencies()
Get a shallow copy of dependencies between this resource and other resources in the same stack.
- Return type:
List
[CfnResource
]
- override_logical_id(new_logical_id)
Overrides the auto-generated logical ID with a specific ID.
- Parameters:
new_logical_id (
str
) – The new logical ID to use for this stack element.- Return type:
None
- remove_dependency(target)
Indicates that this resource no longer depends on another resource.
This can be used for resources across stacks (including nested stacks) and the dependency will automatically be removed from the relevant scope.
- Parameters:
target (
CfnResource
) –- Return type:
None
- replace_dependency(target, new_target)
Replaces one dependency with another.
- Parameters:
target (
CfnResource
) – The dependency to replace.new_target (
CfnResource
) – The new dependency to add.
- Return type:
None
- to_string()
Returns a string representation of this construct.
- Return type:
str
- Returns:
a string representation of this resource
Attributes
- CFN_RESOURCE_TYPE_NAME = 'AWS::EC2::NetworkInterface'
- attr_id
The ID of the network interface.
- CloudformationAttribute:
Id
- attr_primary_ipv6_address
The primary IPv6 address of the network interface.
- CloudformationAttribute:
PrimaryIpv6Address
- attr_primary_private_ip_address
The primary private IP address of the network interface.
For example,
10.0.0.192
.- CloudformationAttribute:
PrimaryPrivateIpAddress
- attr_secondary_private_ip_addresses
The secondary private IP addresses of the network interface.
For example,
["10.0.0.161", "10.0.0.162", "10.0.0.163"]
.- CloudformationAttribute:
SecondaryPrivateIpAddresses
- attr_vpc_id
The ID of the VPC.
- CloudformationAttribute:
VpcId
- cfn_options
Options for this resource, such as condition, update policy etc.
- cfn_resource_type
AWS resource type.
- connection_tracking_specification
A connection tracking specification for the network interface.
- creation_stack
return:
the stack trace of the point where this Resource was created from, sourced from the +metadata+ entry typed +aws:cdk:logicalId+, and with the bottom-most node +internal+ entries filtered.
- description
A description for the network interface.
- enable_primary_ipv6
If you’re modifying a network interface in a dual-stack or IPv6-only subnet, you have the option to assign a primary IPv6 IP address.
- group_set
The IDs of the security groups associated with this network interface.
- interface_type
The type of network interface.
- ipv4_prefix_count
The number of IPv4 prefixes to be automatically assigned to the network interface.
- ipv4_prefixes
The IPv4 delegated prefixes that are assigned to the network interface.
- ipv6_address_count
The number of IPv6 addresses to assign to the network interface.
- ipv6_addresses
The IPv6 addresses from the IPv6 CIDR block range of your subnet to assign to the network interface.
- ipv6_prefix_count
The number of IPv6 prefixes to be automatically assigned to the network interface.
- ipv6_prefixes
The IPv6 delegated prefixes that are assigned to the network interface.
- logical_id
The logical ID for this CloudFormation stack element.
The logical ID of the element is calculated from the path of the resource node in the construct tree.
To override this value, use
overrideLogicalId(newLogicalId)
.- Returns:
the logical ID as a stringified token. This value will only get resolved during synthesis.
- node
The tree node.
- private_ip_address
The private IPv4 address to assign to the network interface as the primary private IP address.
- private_ip_addresses
The private IPv4 addresses to assign to the network interface.
- ref
Return a string that will be resolved to a CloudFormation
{ Ref }
for this element.If, by any chance, the intrinsic reference of a resource is not a string, you could coerce it to an IResolvable through
Lazy.any({ produce: resource.ref })
.
- secondary_private_ip_address_count
The number of secondary private IPv4 addresses to assign to a network interface.
- source_dest_check
Enable or disable source/destination checks, which ensure that the instance is either the source or the destination of any traffic that it receives.
- stack
The stack in which this element is defined.
CfnElements must be defined within a stack scope (directly or indirectly).
- subnet_id
The ID of the subnet to associate with the network interface.
- tags
Tag Manager which manages the tags for this resource.
- tags_raw
The tags to apply to the network interface.
Static Methods
- classmethod is_cfn_element(x)
Returns
true
if a construct is a stack element (i.e. part of the synthesized cloudformation template).Uses duck-typing instead of
instanceof
to allow stack elements from different versions of this library to be included in the same stack.- Parameters:
x (
Any
) –- Return type:
bool
- Returns:
The construct as a stack element or undefined if it is not a stack element.
- classmethod is_cfn_resource(x)
Check whether the given object is a CfnResource.
- Parameters:
x (
Any
) –- Return type:
bool
- classmethod is_construct(x)
Checks if
x
is a construct.Use this method instead of
instanceof
to properly detectConstruct
instances, even when the construct library is symlinked.Explanation: in JavaScript, multiple copies of the
constructs
library on disk are seen as independent, completely different libraries. As a consequence, the classConstruct
in each copy of theconstructs
library is seen as a different class, and an instance of one class will not test asinstanceof
the other class.npm install
will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of theconstructs
library can be accidentally installed, andinstanceof
will behave unpredictably. It is safest to avoid usinginstanceof
, and using this type-testing method instead.- Parameters:
x (
Any
) – Any object.- Return type:
bool
- Returns:
true if
x
is an object created from a class which extendsConstruct
.
ConnectionTrackingSpecificationProperty
- class CfnNetworkInterface.ConnectionTrackingSpecificationProperty(*, tcp_established_timeout=None, udp_stream_timeout=None, udp_timeout=None)
Bases:
object
Configurable options for connection tracking on a network interface.
For more information, see Connection tracking timeouts in the Amazon Elastic Compute Cloud User Guide .
- Parameters:
tcp_established_timeout (
Union
[int
,float
,None
]) – Timeout (in seconds) for idle TCP connections in an established state. Min: 60 seconds. Max: 432000 seconds (5 days). Default: 432000 seconds. Recommended: Less than 432000 seconds.udp_stream_timeout (
Union
[int
,float
,None
]) – Timeout (in seconds) for idle UDP flows classified as streams which have seen more than one request-response transaction. Min: 60 seconds. Max: 180 seconds (3 minutes). Default: 180 seconds.udp_timeout (
Union
[int
,float
,None
]) – Timeout (in seconds) for idle UDP flows that have seen traffic only in a single direction or a single request-response transaction. Min: 30 seconds. Max: 60 seconds. Default: 30 seconds.
- See:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk import aws_ec2 as ec2 connection_tracking_specification_property = ec2.CfnNetworkInterface.ConnectionTrackingSpecificationProperty( tcp_established_timeout=123, udp_stream_timeout=123, udp_timeout=123 )
Attributes
- tcp_established_timeout
Timeout (in seconds) for idle TCP connections in an established state.
Min: 60 seconds. Max: 432000 seconds (5 days). Default: 432000 seconds. Recommended: Less than 432000 seconds.
- udp_stream_timeout
Timeout (in seconds) for idle UDP flows classified as streams which have seen more than one request-response transaction.
Min: 60 seconds. Max: 180 seconds (3 minutes). Default: 180 seconds.
- udp_timeout
Timeout (in seconds) for idle UDP flows that have seen traffic only in a single direction or a single request-response transaction.
Min: 30 seconds. Max: 60 seconds. Default: 30 seconds.
InstanceIpv6AddressProperty
- class CfnNetworkInterface.InstanceIpv6AddressProperty(*, ipv6_address)
Bases:
object
Describes the IPv6 addresses to associate with the network interface.
- Parameters:
ipv6_address (
str
) – An IPv6 address to associate with the network interface.- See:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk import aws_ec2 as ec2 instance_ipv6_address_property = ec2.CfnNetworkInterface.InstanceIpv6AddressProperty( ipv6_address="ipv6Address" )
Attributes
- ipv6_address
An IPv6 address to associate with the network interface.
Ipv4PrefixSpecificationProperty
- class CfnNetworkInterface.Ipv4PrefixSpecificationProperty(*, ipv4_prefix)
Bases:
object
Describes an IPv4 prefix.
- Parameters:
ipv4_prefix (
str
) – The IPv4 prefix. For information, see Assigning prefixes to network interfaces in the Amazon EC2 User Guide .- See:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk import aws_ec2 as ec2 ipv4_prefix_specification_property = ec2.CfnNetworkInterface.Ipv4PrefixSpecificationProperty( ipv4_prefix="ipv4Prefix" )
Attributes
- ipv4_prefix
The IPv4 prefix.
For information, see Assigning prefixes to network interfaces in the Amazon EC2 User Guide .
Ipv6PrefixSpecificationProperty
- class CfnNetworkInterface.Ipv6PrefixSpecificationProperty(*, ipv6_prefix)
Bases:
object
Describes the IPv6 prefix.
- Parameters:
ipv6_prefix (
str
) – The IPv6 prefix. For information, see Assigning prefixes to Amazon EC2 network interfaces in the Amazon Elastic Compute Cloud User Guide .- See:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk import aws_ec2 as ec2 ipv6_prefix_specification_property = ec2.CfnNetworkInterface.Ipv6PrefixSpecificationProperty( ipv6_prefix="ipv6Prefix" )
Attributes
- ipv6_prefix
The IPv6 prefix.
For information, see Assigning prefixes to Amazon EC2 network interfaces in the Amazon Elastic Compute Cloud User Guide .
PrivateIpAddressSpecificationProperty
- class CfnNetworkInterface.PrivateIpAddressSpecificationProperty(*, primary, private_ip_address)
Bases:
object
Describes a secondary private IPv4 address for a network interface.
- Parameters:
primary (
Union
[bool
,IResolvable
]) – Sets the private IP address as the primary private address. You can set only one primary private IP address. If you don’t specify a primary private IP address, Amazon EC2 automatically assigns a primary private IP address.private_ip_address (
str
) – The private IP address of the network interface.
- See:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk import aws_ec2 as ec2 private_ip_address_specification_property = ec2.CfnNetworkInterface.PrivateIpAddressSpecificationProperty( primary=False, private_ip_address="privateIpAddress" )
Attributes
- primary
Sets the private IP address as the primary private address.
You can set only one primary private IP address. If you don’t specify a primary private IP address, Amazon EC2 automatically assigns a primary private IP address.
- private_ip_address
The private IP address of the network interface.