UNPKG

@pulumi/aws

Version:

A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.

344 lines • 14.5 kB
"use strict"; // *** WARNING: this file was generated by pulumi-language-nodejs. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.CoreNetworkPolicyAttachment = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * Manages 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 * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.networkmanager.CoreNetwork("example", {globalNetworkId: exampleAwsNetworkmanagerGlobalNetwork.id}); * const exampleCoreNetworkPolicyAttachment = new aws.networkmanager.CoreNetworkPolicyAttachment("example", { * coreNetworkId: example.id, * policyDocument: exampleAwsNetworkmanagerCoreNetworkPolicyDocument.json, * }); * ``` * * ### 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 basePolicyDocument * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const exampleGlobalNetwork = new aws.networkmanager.GlobalNetwork("example", {}); * const base = aws.networkmanager.getCoreNetworkPolicyDocument({ * coreNetworkConfigurations: [{ * asnRanges: ["65022-65534"], * edgeLocations: [{ * location: "us-west-2", * asn: "65500", * }], * }], * segments: [{ * name: "segment", * }], * }); * const exampleCoreNetwork = new aws.networkmanager.CoreNetwork("example", { * globalNetworkId: exampleGlobalNetwork.id, * basePolicyDocument: base.then(base => base.json), * createBasePolicy: true, * }); * const exampleVpcAttachment = new aws.networkmanager.VpcAttachment("example", { * coreNetworkId: exampleCoreNetwork.id, * subnetArns: exampleAwsSubnet.map(__item => __item.arn), * vpcArn: exampleAwsVpc.arn, * }); * const example = aws.networkmanager.getCoreNetworkPolicyDocumentOutput({ * coreNetworkConfigurations: [{ * asnRanges: ["65022-65534"], * edgeLocations: [{ * location: "us-west-2", * asn: "65500", * }], * }], * segments: [{ * name: "segment", * }], * segmentActions: [{ * action: "create-route", * segment: "segment", * destinationCidrBlocks: ["0.0.0.0/0"], * destinations: [exampleVpcAttachment.id], * }], * }); * const exampleCoreNetworkPolicyAttachment = new aws.networkmanager.CoreNetworkPolicyAttachment("example", { * coreNetworkId: exampleCoreNetwork.id, * policyDocument: example.apply(example => example.json), * }); * ``` * * ### Option 2 - createBasePolicy only * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const exampleGlobalNetwork = new aws.networkmanager.GlobalNetwork("example", {}); * const exampleCoreNetwork = new aws.networkmanager.CoreNetwork("example", { * globalNetworkId: exampleGlobalNetwork.id, * createBasePolicy: true, * }); * const exampleVpcAttachment = new aws.networkmanager.VpcAttachment("example", { * coreNetworkId: exampleCoreNetwork.id, * subnetArns: exampleAwsSubnet.map(__item => __item.arn), * vpcArn: exampleAwsVpc.arn, * }); * const example = aws.networkmanager.getCoreNetworkPolicyDocumentOutput({ * coreNetworkConfigurations: [{ * asnRanges: ["65022-65534"], * edgeLocations: [{ * location: "us-west-2", * }], * }], * segments: [{ * name: "segment", * }], * segmentActions: [{ * action: "create-route", * segment: "segment", * destinationCidrBlocks: ["0.0.0.0/0"], * destinations: [exampleVpcAttachment.id], * }], * }); * const exampleCoreNetworkPolicyAttachment = new aws.networkmanager.CoreNetworkPolicyAttachment("example", { * coreNetworkId: exampleCoreNetwork.id, * policyDocument: example.apply(example => example.json), * }); * ``` * * ### 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 basePolicyDocument * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const exampleGlobalNetwork = new aws.networkmanager.GlobalNetwork("example", {}); * const base = aws.networkmanager.getCoreNetworkPolicyDocument({ * coreNetworkConfigurations: [{ * asnRanges: ["65022-65534"], * edgeLocations: [ * { * location: "us-west-2", * asn: "65500", * }, * { * location: "us-east-1", * asn: "65501", * }, * ], * }], * segments: [{ * name: "segment", * }], * }); * const exampleCoreNetwork = new aws.networkmanager.CoreNetwork("example", { * globalNetworkId: exampleGlobalNetwork.id, * basePolicyDocument: base.then(base => base.json), * createBasePolicy: true, * }); * const exampleUsWest2 = new aws.networkmanager.VpcAttachment("example_us_west_2", { * coreNetworkId: exampleCoreNetwork.id, * subnetArns: exampleUsWest2AwsSubnet.map(__item => __item.arn), * vpcArn: exampleUsWest2AwsVpc.arn, * }); * const exampleUsEast1 = new aws.networkmanager.VpcAttachment("example_us_east_1", { * coreNetworkId: exampleCoreNetwork.id, * subnetArns: exampleUsEast1AwsSubnet.map(__item => __item.arn), * vpcArn: exampleUsEast1AwsVpc.arn, * }); * const example = aws.networkmanager.getCoreNetworkPolicyDocumentOutput({ * coreNetworkConfigurations: [{ * asnRanges: ["65022-65534"], * edgeLocations: [ * { * location: "us-west-2", * asn: "65500", * }, * { * location: "us-east-1", * asn: "65501", * }, * ], * }], * segments: [ * { * name: "segment", * }, * { * name: "segment2", * }, * ], * segmentActions: [ * { * action: "create-route", * segment: "segment", * destinationCidrBlocks: ["10.0.0.0/16"], * destinations: [exampleUsWest2.id], * }, * { * action: "create-route", * segment: "segment", * destinationCidrBlocks: ["10.1.0.0/16"], * destinations: [exampleUsEast1.id], * }, * ], * }); * const exampleCoreNetworkPolicyAttachment = new aws.networkmanager.CoreNetworkPolicyAttachment("example", { * coreNetworkId: exampleCoreNetwork.id, * policyDocument: example.apply(example => example.json), * }); * ``` * * ### Option 2 - using basePolicyRegions * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const exampleGlobalNetwork = new aws.networkmanager.GlobalNetwork("example", {}); * const exampleCoreNetwork = new aws.networkmanager.CoreNetwork("example", { * globalNetworkId: exampleGlobalNetwork.id, * basePolicyRegions: [ * "us-west-2", * "us-east-1", * ], * createBasePolicy: true, * }); * const exampleUsWest2 = new aws.networkmanager.VpcAttachment("example_us_west_2", { * coreNetworkId: exampleCoreNetwork.id, * subnetArns: exampleUsWest2AwsSubnet.map(__item => __item.arn), * vpcArn: exampleUsWest2AwsVpc.arn, * }); * const exampleUsEast1 = new aws.networkmanager.VpcAttachment("example_us_east_1", { * coreNetworkId: exampleCoreNetwork.id, * subnetArns: exampleUsEast1AwsSubnet.map(__item => __item.arn), * vpcArn: exampleUsEast1AwsVpc.arn, * }); * const example = aws.networkmanager.getCoreNetworkPolicyDocumentOutput({ * coreNetworkConfigurations: [{ * asnRanges: ["65022-65534"], * edgeLocations: [ * { * location: "us-west-2", * }, * { * location: "us-east-1", * }, * ], * }], * segments: [ * { * name: "segment", * }, * { * name: "segment2", * }, * ], * segmentActions: [ * { * action: "create-route", * segment: "segment", * destinationCidrBlocks: ["10.0.0.0/16"], * destinations: [exampleUsWest2.id], * }, * { * action: "create-route", * segment: "segment", * destinationCidrBlocks: ["10.1.0.0/16"], * destinations: [exampleUsEast1.id], * }, * ], * }); * const exampleCoreNetworkPolicyAttachment = new aws.networkmanager.CoreNetworkPolicyAttachment("example", { * coreNetworkId: exampleCoreNetwork.id, * policyDocument: example.apply(example => example.json), * }); * ``` * * ## Import * * Using `pulumi import`, import `aws_networkmanager_core_network_policy_attachment` using the core network ID. For example: * * ```sh * $ pulumi import aws:networkmanager/coreNetworkPolicyAttachment:CoreNetworkPolicyAttachment example core-network-0d47f6t230mz46dy4 * ``` */ class CoreNetworkPolicyAttachment extends pulumi.CustomResource { /** * Get an existing CoreNetworkPolicyAttachment resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name, id, state, opts) { return new CoreNetworkPolicyAttachment(name, state, { ...opts, id: id }); } /** * Returns true if the given object is an instance of CoreNetworkPolicyAttachment. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj) { if (obj === undefined || obj === null) { return false; } return obj['__pulumiType'] === CoreNetworkPolicyAttachment.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["coreNetworkId"] = state?.coreNetworkId; resourceInputs["policyDocument"] = state?.policyDocument; resourceInputs["state"] = state?.state; } else { const args = argsOrState; if (args?.coreNetworkId === undefined && !opts.urn) { throw new Error("Missing required property 'coreNetworkId'"); } if (args?.policyDocument === undefined && !opts.urn) { throw new Error("Missing required property 'policyDocument'"); } resourceInputs["coreNetworkId"] = args?.coreNetworkId; resourceInputs["policyDocument"] = args?.policyDocument; resourceInputs["state"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(CoreNetworkPolicyAttachment.__pulumiType, name, resourceInputs, opts); } } exports.CoreNetworkPolicyAttachment = CoreNetworkPolicyAttachment; /** @internal */ CoreNetworkPolicyAttachment.__pulumiType = 'aws:networkmanager/coreNetworkPolicyAttachment:CoreNetworkPolicyAttachment'; //# sourceMappingURL=coreNetworkPolicyAttachment.js.map