Package com.pulumi.aws.networkmanager
Class CoreNetworkPolicyAttachment
- java.lang.Object
-
- com.pulumi.resources.Resource
-
- com.pulumi.resources.CustomResource
-
- com.pulumi.aws.networkmanager.CoreNetworkPolicyAttachment
-
public class CoreNetworkPolicyAttachment extends com.pulumi.resources.CustomResourceManages a Network Manager Core Network Policy Attachment. Use this resource to attach a Core Network Policy to an existing Core Network and execute the change set, which deploys changes globally based on the policy submitted (sets the policy to `LIVE`). > **NOTE:** Deleting this resource will not delete the current policy defined in this resource. Deleting this resource will also not revert the current `LIVE` policy to the previous version. ## Example Usage ### Basic
### With VPC Attachment (Single Region) The example below illustrates the scenario where your policy document has static routes pointing to VPC attachments and you want to attach your VPCs to the core network before applying the desired policy document. Set the `createBasePolicy` argument of the `aws.networkmanager.CoreNetwork` resource to `true` if your core network does not currently have any `LIVE` policies (e.g. this is the first `pulumi up` with the core network resource), since a `LIVE` policy is required before VPCs can be attached to the core network. Otherwise, if your core network already has a `LIVE` policy, you may exclude the `createBasePolicy` argument. There are 2 options to implement this: - Option 1: Use the `basePolicyDocument` argument in the `aws.networkmanager.CoreNetwork` resource that allows the most customizations to a base policy. Use this to customize the `edgeLocations` `asn`. In the example below, `us-west-2` and ASN `65500` are used in the base policy. - Option 2: Use the `createBasePolicy` argument only. This creates a base policy in the region specified in the `provider` block. ### Option 1 - using basePolicyDocumentpackage generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.aws.networkmanager.CoreNetwork; import com.pulumi.aws.networkmanager.CoreNetworkArgs; import com.pulumi.aws.networkmanager.CoreNetworkPolicyAttachment; import com.pulumi.aws.networkmanager.CoreNetworkPolicyAttachmentArgs; import java.util.ArrayList; import java.util.Arrays; import java.util.Map; import java.io.File; import java.nio.file.Files; import java.nio.file.Paths; public class App { public static void main(String[] args) { Pulumi.run(App::stack); } public static void stack(Context ctx) { var example = new CoreNetwork("example", CoreNetworkArgs.builder() .globalNetworkId(exampleAwsNetworkmanagerGlobalNetwork.id()) .build()); var exampleCoreNetworkPolicyAttachment = new CoreNetworkPolicyAttachment("exampleCoreNetworkPolicyAttachment", CoreNetworkPolicyAttachmentArgs.builder() .coreNetworkId(example.id()) .policyDocument(exampleAwsNetworkmanagerCoreNetworkPolicyDocument.json()) .build()); } }
### Option 2 - createBasePolicy onlypackage generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.aws.networkmanager.GlobalNetwork; import com.pulumi.aws.networkmanager.NetworkmanagerFunctions; import com.pulumi.aws.networkmanager.inputs.GetCoreNetworkPolicyDocumentArgs; import com.pulumi.aws.networkmanager.inputs.GetCoreNetworkPolicyDocumentCoreNetworkConfigurationArgs; import com.pulumi.aws.networkmanager.inputs.GetCoreNetworkPolicyDocumentCoreNetworkConfigurationEdgeLocationArgs; import com.pulumi.aws.networkmanager.inputs.GetCoreNetworkPolicyDocumentSegmentArgs; import com.pulumi.aws.networkmanager.CoreNetwork; import com.pulumi.aws.networkmanager.CoreNetworkArgs; import com.pulumi.aws.networkmanager.VpcAttachment; import com.pulumi.aws.networkmanager.VpcAttachmentArgs; import com.pulumi.aws.networkmanager.inputs.GetCoreNetworkPolicyDocumentSegmentActionArgs; import com.pulumi.aws.networkmanager.CoreNetworkPolicyAttachment; import com.pulumi.aws.networkmanager.CoreNetworkPolicyAttachmentArgs; import java.util.ArrayList; import java.util.Arrays; import java.util.Map; import java.io.File; import java.nio.file.Files; import java.nio.file.Paths; public class App { public static void main(String[] args) { Pulumi.run(App::stack); } public static void stack(Context ctx) { var exampleGlobalNetwork = new GlobalNetwork("exampleGlobalNetwork"); final var base = NetworkmanagerFunctions.getCoreNetworkPolicyDocument(GetCoreNetworkPolicyDocumentArgs.builder() .coreNetworkConfigurations(GetCoreNetworkPolicyDocumentCoreNetworkConfigurationArgs.builder() .edgeLocations(GetCoreNetworkPolicyDocumentCoreNetworkConfigurationEdgeLocationArgs.builder() .location("us-west-2") .asn("65500") .build()) .asnRanges("65022-65534") .build()) .segments(GetCoreNetworkPolicyDocumentSegmentArgs.builder() .name("segment") .build()) .build()); var exampleCoreNetwork = new CoreNetwork("exampleCoreNetwork", CoreNetworkArgs.builder() .globalNetworkId(exampleGlobalNetwork.id()) .basePolicyDocument(base.json()) .createBasePolicy(true) .build()); var exampleVpcAttachment = new VpcAttachment("exampleVpcAttachment", VpcAttachmentArgs.builder() .coreNetworkId(exampleCoreNetwork.id()) .subnetArns(exampleAwsSubnet.stream().map(element -> element.arn()).collect(toList())) .vpcArn(exampleAwsVpc.arn()) .build()); final var example = NetworkmanagerFunctions.getCoreNetworkPolicyDocument(GetCoreNetworkPolicyDocumentArgs.builder() .coreNetworkConfigurations(GetCoreNetworkPolicyDocumentCoreNetworkConfigurationArgs.builder() .edgeLocations(GetCoreNetworkPolicyDocumentCoreNetworkConfigurationEdgeLocationArgs.builder() .location("us-west-2") .asn("65500") .build()) .asnRanges("65022-65534") .build()) .segmentActions(GetCoreNetworkPolicyDocumentSegmentActionArgs.builder() .action("create-route") .segment("segment") .destinationCidrBlocks("0.0.0.0/0") .destinations(exampleVpcAttachment.id()) .build()) .segments(GetCoreNetworkPolicyDocumentSegmentArgs.builder() .name("segment") .build()) .build()); var exampleCoreNetworkPolicyAttachment = new CoreNetworkPolicyAttachment("exampleCoreNetworkPolicyAttachment", CoreNetworkPolicyAttachmentArgs.builder() .coreNetworkId(exampleCoreNetwork.id()) .policyDocument(example.applyValue(_example -> _example.json())) .build()); } }
### With VPC Attachment (Multi-Region) The example below illustrates the scenario where your policy document has static routes pointing to VPC attachments and you want to attach your VPCs to the core network before applying the desired policy document. Set the `createBasePolicy` argument of the `aws.networkmanager.CoreNetwork` resource to `true` if your core network does not currently have any `LIVE` policies (e.g. this is the first `pulumi up` with the core network resource), since a `LIVE` policy is required before VPCs can be attached to the core network. Otherwise, if your core network already has a `LIVE` policy, you may exclude the `createBasePolicy` argument. For multi-region in a core network that does not yet have a `LIVE` policy, there are 2 options: - Option 1: Use the `basePolicyDocument` argument that allows the most customizations to a base policy. Use this to customize the `edgeLocations` `asn`. In the example below, `us-west-2`, `us-east-1` and specific ASNs are used in the base policy. - Option 2: Pass a list of regions to the `aws.networkmanager.CoreNetwork` resource `basePolicyRegions` argument. In the example below, `us-west-2` and `us-east-1` are specified in the base policy. ### Option 1 - using basePolicyDocumentpackage generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.aws.networkmanager.GlobalNetwork; import com.pulumi.aws.networkmanager.CoreNetwork; import com.pulumi.aws.networkmanager.CoreNetworkArgs; import com.pulumi.aws.networkmanager.VpcAttachment; import com.pulumi.aws.networkmanager.VpcAttachmentArgs; import com.pulumi.aws.networkmanager.NetworkmanagerFunctions; import com.pulumi.aws.networkmanager.inputs.GetCoreNetworkPolicyDocumentArgs; import com.pulumi.aws.networkmanager.inputs.GetCoreNetworkPolicyDocumentCoreNetworkConfigurationArgs; import com.pulumi.aws.networkmanager.inputs.GetCoreNetworkPolicyDocumentCoreNetworkConfigurationEdgeLocationArgs; import com.pulumi.aws.networkmanager.inputs.GetCoreNetworkPolicyDocumentSegmentActionArgs; import com.pulumi.aws.networkmanager.inputs.GetCoreNetworkPolicyDocumentSegmentArgs; import com.pulumi.aws.networkmanager.CoreNetworkPolicyAttachment; import com.pulumi.aws.networkmanager.CoreNetworkPolicyAttachmentArgs; import java.util.ArrayList; import java.util.Arrays; import java.util.Map; import java.io.File; import java.nio.file.Files; import java.nio.file.Paths; public class App { public static void main(String[] args) { Pulumi.run(App::stack); } public static void stack(Context ctx) { var exampleGlobalNetwork = new GlobalNetwork("exampleGlobalNetwork"); var exampleCoreNetwork = new CoreNetwork("exampleCoreNetwork", CoreNetworkArgs.builder() .globalNetworkId(exampleGlobalNetwork.id()) .createBasePolicy(true) .build()); var exampleVpcAttachment = new VpcAttachment("exampleVpcAttachment", VpcAttachmentArgs.builder() .coreNetworkId(exampleCoreNetwork.id()) .subnetArns(exampleAwsSubnet.stream().map(element -> element.arn()).collect(toList())) .vpcArn(exampleAwsVpc.arn()) .build()); final var example = NetworkmanagerFunctions.getCoreNetworkPolicyDocument(GetCoreNetworkPolicyDocumentArgs.builder() .coreNetworkConfigurations(GetCoreNetworkPolicyDocumentCoreNetworkConfigurationArgs.builder() .edgeLocations(GetCoreNetworkPolicyDocumentCoreNetworkConfigurationEdgeLocationArgs.builder() .location("us-west-2") .build()) .asnRanges("65022-65534") .build()) .segmentActions(GetCoreNetworkPolicyDocumentSegmentActionArgs.builder() .action("create-route") .segment("segment") .destinationCidrBlocks("0.0.0.0/0") .destinations(exampleVpcAttachment.id()) .build()) .segments(GetCoreNetworkPolicyDocumentSegmentArgs.builder() .name("segment") .build()) .build()); var exampleCoreNetworkPolicyAttachment = new CoreNetworkPolicyAttachment("exampleCoreNetworkPolicyAttachment", CoreNetworkPolicyAttachmentArgs.builder() .coreNetworkId(exampleCoreNetwork.id()) .policyDocument(example.applyValue(_example -> _example.json())) .build()); } }
### Option 2 - using basePolicyRegionspackage generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.aws.networkmanager.GlobalNetwork; import com.pulumi.aws.networkmanager.NetworkmanagerFunctions; import com.pulumi.aws.networkmanager.inputs.GetCoreNetworkPolicyDocumentArgs; import com.pulumi.aws.networkmanager.inputs.GetCoreNetworkPolicyDocumentCoreNetworkConfigurationArgs; import com.pulumi.aws.networkmanager.inputs.GetCoreNetworkPolicyDocumentCoreNetworkConfigurationEdgeLocationArgs; import com.pulumi.aws.networkmanager.inputs.GetCoreNetworkPolicyDocumentSegmentArgs; import com.pulumi.aws.networkmanager.CoreNetwork; import com.pulumi.aws.networkmanager.CoreNetworkArgs; import com.pulumi.aws.networkmanager.VpcAttachment; import com.pulumi.aws.networkmanager.VpcAttachmentArgs; import com.pulumi.aws.networkmanager.inputs.GetCoreNetworkPolicyDocumentSegmentActionArgs; import com.pulumi.aws.networkmanager.CoreNetworkPolicyAttachment; import com.pulumi.aws.networkmanager.CoreNetworkPolicyAttachmentArgs; import java.util.ArrayList; import java.util.Arrays; import java.util.Map; import java.io.File; import java.nio.file.Files; import java.nio.file.Paths; public class App { public static void main(String[] args) { Pulumi.run(App::stack); } public static void stack(Context ctx) { var exampleGlobalNetwork = new GlobalNetwork("exampleGlobalNetwork"); final var base = NetworkmanagerFunctions.getCoreNetworkPolicyDocument(GetCoreNetworkPolicyDocumentArgs.builder() .coreNetworkConfigurations(GetCoreNetworkPolicyDocumentCoreNetworkConfigurationArgs.builder() .edgeLocations( GetCoreNetworkPolicyDocumentCoreNetworkConfigurationEdgeLocationArgs.builder() .location("us-west-2") .asn("65500") .build(), GetCoreNetworkPolicyDocumentCoreNetworkConfigurationEdgeLocationArgs.builder() .location("us-east-1") .asn("65501") .build()) .asnRanges("65022-65534") .build()) .segments(GetCoreNetworkPolicyDocumentSegmentArgs.builder() .name("segment") .build()) .build()); var exampleCoreNetwork = new CoreNetwork("exampleCoreNetwork", CoreNetworkArgs.builder() .globalNetworkId(exampleGlobalNetwork.id()) .basePolicyDocument(base.json()) .createBasePolicy(true) .build()); var exampleUsWest2 = new VpcAttachment("exampleUsWest2", VpcAttachmentArgs.builder() .coreNetworkId(exampleCoreNetwork.id()) .subnetArns(exampleUsWest2AwsSubnet.stream().map(element -> element.arn()).collect(toList())) .vpcArn(exampleUsWest2AwsVpc.arn()) .build()); var exampleUsEast1 = new VpcAttachment("exampleUsEast1", VpcAttachmentArgs.builder() .coreNetworkId(exampleCoreNetwork.id()) .subnetArns(exampleUsEast1AwsSubnet.stream().map(element -> element.arn()).collect(toList())) .vpcArn(exampleUsEast1AwsVpc.arn()) .build()); final var example = NetworkmanagerFunctions.getCoreNetworkPolicyDocument(GetCoreNetworkPolicyDocumentArgs.builder() .coreNetworkConfigurations(GetCoreNetworkPolicyDocumentCoreNetworkConfigurationArgs.builder() .edgeLocations( GetCoreNetworkPolicyDocumentCoreNetworkConfigurationEdgeLocationArgs.builder() .location("us-west-2") .asn("65500") .build(), GetCoreNetworkPolicyDocumentCoreNetworkConfigurationEdgeLocationArgs.builder() .location("us-east-1") .asn("65501") .build()) .asnRanges("65022-65534") .build()) .segmentActions( GetCoreNetworkPolicyDocumentSegmentActionArgs.builder() .action("create-route") .segment("segment") .destinationCidrBlocks("10.0.0.0/16") .destinations(exampleUsWest2.id()) .build(), GetCoreNetworkPolicyDocumentSegmentActionArgs.builder() .action("create-route") .segment("segment") .destinationCidrBlocks("10.1.0.0/16") .destinations(exampleUsEast1.id()) .build()) .segments( GetCoreNetworkPolicyDocumentSegmentArgs.builder() .name("segment") .build(), GetCoreNetworkPolicyDocumentSegmentArgs.builder() .name("segment2") .build()) .build()); var exampleCoreNetworkPolicyAttachment = new CoreNetworkPolicyAttachment("exampleCoreNetworkPolicyAttachment", CoreNetworkPolicyAttachmentArgs.builder() .coreNetworkId(exampleCoreNetwork.id()) .policyDocument(example.applyValue(_example -> _example.json())) .build()); } }
## Import Using `pulumi import`, import `aws.networkmanager.CoreNetworkPolicyAttachment` using the core network ID. For example: ```sh $ pulumi import aws:networkmanager/coreNetworkPolicyAttachment:CoreNetworkPolicyAttachment example core-network-0d47f6t230mz46dy4 ```package generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.aws.networkmanager.GlobalNetwork; import com.pulumi.aws.networkmanager.CoreNetwork; import com.pulumi.aws.networkmanager.CoreNetworkArgs; import com.pulumi.aws.networkmanager.VpcAttachment; import com.pulumi.aws.networkmanager.VpcAttachmentArgs; import com.pulumi.aws.networkmanager.NetworkmanagerFunctions; import com.pulumi.aws.networkmanager.inputs.GetCoreNetworkPolicyDocumentArgs; import com.pulumi.aws.networkmanager.inputs.GetCoreNetworkPolicyDocumentCoreNetworkConfigurationArgs; import com.pulumi.aws.networkmanager.inputs.GetCoreNetworkPolicyDocumentCoreNetworkConfigurationEdgeLocationArgs; import com.pulumi.aws.networkmanager.inputs.GetCoreNetworkPolicyDocumentSegmentActionArgs; import com.pulumi.aws.networkmanager.inputs.GetCoreNetworkPolicyDocumentSegmentArgs; import com.pulumi.aws.networkmanager.CoreNetworkPolicyAttachment; import com.pulumi.aws.networkmanager.CoreNetworkPolicyAttachmentArgs; import java.util.ArrayList; import java.util.Arrays; import java.util.Map; import java.io.File; import java.nio.file.Files; import java.nio.file.Paths; public class App { public static void main(String[] args) { Pulumi.run(App::stack); } public static void stack(Context ctx) { var exampleGlobalNetwork = new GlobalNetwork("exampleGlobalNetwork"); var exampleCoreNetwork = new CoreNetwork("exampleCoreNetwork", CoreNetworkArgs.builder() .globalNetworkId(exampleGlobalNetwork.id()) .basePolicyRegions( "us-west-2", "us-east-1") .createBasePolicy(true) .build()); var exampleUsWest2 = new VpcAttachment("exampleUsWest2", VpcAttachmentArgs.builder() .coreNetworkId(exampleCoreNetwork.id()) .subnetArns(exampleUsWest2AwsSubnet.stream().map(element -> element.arn()).collect(toList())) .vpcArn(exampleUsWest2AwsVpc.arn()) .build()); var exampleUsEast1 = new VpcAttachment("exampleUsEast1", VpcAttachmentArgs.builder() .coreNetworkId(exampleCoreNetwork.id()) .subnetArns(exampleUsEast1AwsSubnet.stream().map(element -> element.arn()).collect(toList())) .vpcArn(exampleUsEast1AwsVpc.arn()) .build()); final var example = NetworkmanagerFunctions.getCoreNetworkPolicyDocument(GetCoreNetworkPolicyDocumentArgs.builder() .coreNetworkConfigurations(GetCoreNetworkPolicyDocumentCoreNetworkConfigurationArgs.builder() .edgeLocations( GetCoreNetworkPolicyDocumentCoreNetworkConfigurationEdgeLocationArgs.builder() .location("us-west-2") .build(), GetCoreNetworkPolicyDocumentCoreNetworkConfigurationEdgeLocationArgs.builder() .location("us-east-1") .build()) .asnRanges("65022-65534") .build()) .segmentActions( GetCoreNetworkPolicyDocumentSegmentActionArgs.builder() .action("create-route") .segment("segment") .destinationCidrBlocks("10.0.0.0/16") .destinations(exampleUsWest2.id()) .build(), GetCoreNetworkPolicyDocumentSegmentActionArgs.builder() .action("create-route") .segment("segment") .destinationCidrBlocks("10.1.0.0/16") .destinations(exampleUsEast1.id()) .build()) .segments( GetCoreNetworkPolicyDocumentSegmentArgs.builder() .name("segment") .build(), GetCoreNetworkPolicyDocumentSegmentArgs.builder() .name("segment2") .build()) .build()); var exampleCoreNetworkPolicyAttachment = new CoreNetworkPolicyAttachment("exampleCoreNetworkPolicyAttachment", CoreNetworkPolicyAttachmentArgs.builder() .coreNetworkId(exampleCoreNetwork.id()) .policyDocument(example.applyValue(_example -> _example.json())) .build()); } }
-
-
Constructor Summary
Constructors Constructor Description CoreNetworkPolicyAttachment(java.lang.String name)CoreNetworkPolicyAttachment(java.lang.String name, CoreNetworkPolicyAttachmentArgs args)CoreNetworkPolicyAttachment(java.lang.String name, CoreNetworkPolicyAttachmentArgs args, com.pulumi.resources.CustomResourceOptions options)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description com.pulumi.core.Output<java.lang.String>coreNetworkId()static CoreNetworkPolicyAttachmentget(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, CoreNetworkPolicyAttachmentState state, com.pulumi.resources.CustomResourceOptions options)Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.com.pulumi.core.Output<java.lang.String>policyDocument()com.pulumi.core.Output<java.lang.String>state()
-
-
-
Constructor Detail
-
CoreNetworkPolicyAttachment
public CoreNetworkPolicyAttachment(java.lang.String name)
- Parameters:
name- The _unique_ name of the resulting resource.
-
CoreNetworkPolicyAttachment
public CoreNetworkPolicyAttachment(java.lang.String name, CoreNetworkPolicyAttachmentArgs args)- Parameters:
name- The _unique_ name of the resulting resource.args- The arguments to use to populate this resource's properties.
-
CoreNetworkPolicyAttachment
public CoreNetworkPolicyAttachment(java.lang.String name, CoreNetworkPolicyAttachmentArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options)- Parameters:
name- The _unique_ name of the resulting resource.args- The arguments to use to populate this resource's properties.options- A bag of options that control this resource's behavior.
-
-
Method Detail
-
coreNetworkId
public com.pulumi.core.Output<java.lang.String> coreNetworkId()
- Returns:
- ID of the core network that a policy will be attached to and made `LIVE`.
-
policyDocument
public com.pulumi.core.Output<java.lang.String> policyDocument()
- Returns:
- Policy document for creating a core network. Note that updating this argument will result in the new policy document version being set as the `LATEST` and `LIVE` policy document. Refer to the [Core network policies documentation](https://docs.aws.amazon.com/network-manager/latest/cloudwan/cloudwan-policy-change-sets.html) for more information.
-
state
public com.pulumi.core.Output<java.lang.String> state()
- Returns:
- Current state of a core network.
-
get
public static CoreNetworkPolicyAttachment get(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, @Nullable CoreNetworkPolicyAttachmentState state, @Nullable com.pulumi.resources.CustomResourceOptions options)
Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.- Parameters:
name- The _unique_ name of the resulting resource.id- The _unique_ provider ID of the resource to lookup.state-options- Optional settings to control the behavior of the CustomResource.
-
-