CoreNetworkPolicyAttachmentArgs

data class CoreNetworkPolicyAttachmentArgs(val coreNetworkId: Output<String>? = null, val policyDocument: Output<String>? = null) : ConvertibleToJava<CoreNetworkPolicyAttachmentArgs>

Provides a Core Network Policy Attachment resource. This puts a Core Network Policy to an existing Core Network and executes the change set, which deploys changes globally based on the policy submitted (Sets the policy to LIVE).

NOTE on Core Networks and Policy Attachments: For a given policy attachment, this resource is incompatible with using the aws.networkmanager.CoreNetwork resource policy_document argument. When using that argument and this resource, both will attempt to manage the core network's policy document and Pulumi will show a permanent difference. 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

package 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.List;
import java.util.ArrayList;
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 exampleCoreNetwork = new CoreNetwork("exampleCoreNetwork", CoreNetworkArgs.builder()
.globalNetworkId(aws_networkmanager_global_network.example().id())
.build());
var exampleCoreNetworkPolicyAttachment = new CoreNetworkPolicyAttachment("exampleCoreNetworkPolicyAttachment", CoreNetworkPolicyAttachmentArgs.builder()
.coreNetworkId(exampleCoreNetwork.id())
.policyDocument(data.aws_networkmanager_core_network_policy_document().example().json())
.build());
}
}

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 create_base_policy 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 create_base_policy argument.

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.CoreNetworkPolicyAttachment;
import com.pulumi.aws.networkmanager.CoreNetworkPolicyAttachmentArgs;
import java.util.List;
import java.util.ArrayList;
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(aws_subnet.example().stream().map(element -> element.arn()).collect(toList()))
.vpcArn(aws_vpc.example().arn())
.build());
final var exampleCoreNetworkPolicyDocument = NetworkmanagerFunctions.getCoreNetworkPolicyDocument(GetCoreNetworkPolicyDocumentArgs.builder()
.coreNetworkConfigurations(GetCoreNetworkPolicyDocumentCoreNetworkConfigurationArgs.builder()
.asnRanges("65022-65534")
.edgeLocations(GetCoreNetworkPolicyDocumentCoreNetworkConfigurationEdgeLocationArgs.builder()
.location("us-west-2")
.build())
.build())
.segments(GetCoreNetworkPolicyDocumentSegmentArgs.builder()
.name("segment")
.build())
.segmentActions(GetCoreNetworkPolicyDocumentSegmentActionArgs.builder()
.action("create-route")
.segment("segment")
.destinationCidrBlocks("0.0.0.0/0")
.destinations(exampleVpcAttachment.id())
.build())
.build());
var exampleCoreNetworkPolicyAttachment = new CoreNetworkPolicyAttachment("exampleCoreNetworkPolicyAttachment", CoreNetworkPolicyAttachmentArgs.builder()
.coreNetworkId(exampleCoreNetwork.id())
.policyDocument(exampleCoreNetworkPolicyDocument.applyValue(getCoreNetworkPolicyDocumentResult -> getCoreNetworkPolicyDocumentResult).applyValue(exampleCoreNetworkPolicyDocument -> exampleCoreNetworkPolicyDocument.applyValue(getCoreNetworkPolicyDocumentResult -> getCoreNetworkPolicyDocumentResult.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 create_base_policy 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 create_base_policy argument. For multi-region in a core network that does not yet have a LIVE policy, pass a list of regions to the aws.networkmanager.CoreNetwork base_policy_regions argument. In the example below, us-west-2 and us-east-1 are specified in the base policy.

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.CoreNetworkPolicyAttachment;
import com.pulumi.aws.networkmanager.CoreNetworkPolicyAttachmentArgs;
import com.pulumi.resources.CustomResourceOptions;
import java.util.List;
import java.util.ArrayList;
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(aws_subnet.example_us_west_2().stream().map(element -> element.arn()).collect(toList()))
.vpcArn(aws_vpc.example_us_west_2().arn())
.build());
var exampleUsEast1 = new VpcAttachment("exampleUsEast1", VpcAttachmentArgs.builder()
.coreNetworkId(exampleCoreNetwork.id())
.subnetArns(aws_subnet.example_us_east_1().stream().map(element -> element.arn()).collect(toList()))
.vpcArn(aws_vpc.example_us_east_1().arn())
.build(), CustomResourceOptions.builder()
.provider("alternate")
.build());
final var exampleCoreNetworkPolicyDocument = NetworkmanagerFunctions.getCoreNetworkPolicyDocument(GetCoreNetworkPolicyDocumentArgs.builder()
.coreNetworkConfigurations(GetCoreNetworkPolicyDocumentCoreNetworkConfigurationArgs.builder()
.asnRanges("65022-65534")
.edgeLocations(
GetCoreNetworkPolicyDocumentCoreNetworkConfigurationEdgeLocationArgs.builder()
.location("us-west-2")
.build(),
GetCoreNetworkPolicyDocumentCoreNetworkConfigurationEdgeLocationArgs.builder()
.location("us-east-1")
.build())
.build())
.segments(
GetCoreNetworkPolicyDocumentSegmentArgs.builder()
.name("segment")
.build(),
GetCoreNetworkPolicyDocumentSegmentArgs.builder()
.name("segment2")
.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())
.build());
var exampleCoreNetworkPolicyAttachment = new CoreNetworkPolicyAttachment("exampleCoreNetworkPolicyAttachment", CoreNetworkPolicyAttachmentArgs.builder()
.coreNetworkId(exampleCoreNetwork.id())
.policyDocument(exampleCoreNetworkPolicyDocument.applyValue(getCoreNetworkPolicyDocumentResult -> getCoreNetworkPolicyDocumentResult).applyValue(exampleCoreNetworkPolicyDocument -> exampleCoreNetworkPolicyDocument.applyValue(getCoreNetworkPolicyDocumentResult -> getCoreNetworkPolicyDocumentResult.json())))
.build());
}
}

Import

aws_networkmanager_core_network_policy_attachment can be imported using the core network ID, e.g.

$ pulumi import aws:networkmanager/coreNetworkPolicyAttachment:CoreNetworkPolicyAttachment example core-network-0d47f6t230mz46dy4

Constructors

Link copied to clipboard
constructor(coreNetworkId: Output<String>? = null, policyDocument: Output<String>? = null)

Properties

Link copied to clipboard
val coreNetworkId: Output<String>? = null

The ID of the core network that a policy will be attached to and made LIVE.

Link copied to clipboard
val policyDocument: Output<String>? = null

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 for more information.

Functions

Link copied to clipboard
open override fun toJava(): CoreNetworkPolicyAttachmentArgs