UNPKG

@pulumi/aws

Version:

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

173 lines 9.44 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.StackSetInstance = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * Manages a CloudFormation StackSet Instance. Instances are managed in the account and region of the StackSet after the target account permissions have been configured. Additional information about StackSets can be found in the [AWS CloudFormation User Guide](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/what-is-cfnstacksets.html). * * > **NOTE:** All target accounts must have an IAM Role created that matches the name of the execution role configured in the StackSet (the `executionRoleName` argument in the `aws.cloudformation.StackSet` resource) in a trust relationship with the administrative account or administration IAM Role. The execution role must have appropriate permissions to manage resources defined in the template along with those required for StackSets to operate. See the [AWS CloudFormation User Guide](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stacksets-prereqs.html) for more details. * * > **NOTE:** To retain the Stack during resource destroy, ensure `retainStack` has been set to `true` in the state first. This must be completed _before_ a deployment that would destroy the resource. * * ## Example Usage * * ### Basic Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.cloudformation.StackSetInstance("example", { * accountId: "123456789012", * stackSetInstanceRegion: "us-east-1", * stackSetName: exampleAwsCloudformationStackSet.name, * }); * ``` * * ### Example IAM Setup in Target Account * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const aWSCloudFormationStackSetExecutionRoleAssumeRolePolicy = aws.iam.getPolicyDocument({ * statements: [{ * actions: ["sts:AssumeRole"], * effect: "Allow", * principals: [{ * identifiers: [aWSCloudFormationStackSetAdministrationRole.arn], * type: "AWS", * }], * }], * }); * const aWSCloudFormationStackSetExecutionRole = new aws.iam.Role("AWSCloudFormationStackSetExecutionRole", { * assumeRolePolicy: aWSCloudFormationStackSetExecutionRoleAssumeRolePolicy.then(aWSCloudFormationStackSetExecutionRoleAssumeRolePolicy => aWSCloudFormationStackSetExecutionRoleAssumeRolePolicy.json), * name: "AWSCloudFormationStackSetExecutionRole", * }); * // Documentation: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stacksets-prereqs.html * // Additional IAM permissions necessary depend on the resources defined in the StackSet template * const aWSCloudFormationStackSetExecutionRoleMinimumExecutionPolicy = aws.iam.getPolicyDocument({ * statements: [{ * actions: [ * "cloudformation:*", * "s3:*", * "sns:*", * ], * effect: "Allow", * resources: ["*"], * }], * }); * const aWSCloudFormationStackSetExecutionRoleMinimumExecutionPolicyRolePolicy = new aws.iam.RolePolicy("AWSCloudFormationStackSetExecutionRole_MinimumExecutionPolicy", { * name: "MinimumExecutionPolicy", * policy: aWSCloudFormationStackSetExecutionRoleMinimumExecutionPolicy.then(aWSCloudFormationStackSetExecutionRoleMinimumExecutionPolicy => aWSCloudFormationStackSetExecutionRoleMinimumExecutionPolicy.json), * role: aWSCloudFormationStackSetExecutionRole.name, * }); * ``` * * ### Example Deployment across Organizations account * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.cloudformation.StackSetInstance("example", { * deploymentTargets: { * organizationalUnitIds: [exampleAwsOrganizationsOrganization.roots[0].id], * }, * stackSetInstanceRegion: "us-east-1", * stackSetName: exampleAwsCloudformationStackSet.name, * }); * ``` * * ## Import * * Import CloudFormation StackSet Instances that target AWS Organizational Units using the StackSet name, a slash (`/`) separated list of organizational unit IDs, and target AWS Region separated by commas (`,`). For example: * * Import CloudFormation StackSet Instances when acting a delegated administrator in a member account using the StackSet name, target AWS account ID or slash (`/`) separated list of organizational unit IDs, target AWS Region and `call_as` value separated by commas (`,`). For example: * * Using `pulumi import`, import CloudFormation StackSet Instances that target an AWS Account ID using the StackSet name, target AWS account ID, and target AWS Region separated by commas (`,`). For example: * * ```sh * $ pulumi import aws:cloudformation/stackSetInstance:StackSetInstance example example,123456789012,us-east-1 * ``` * Using `pulumi import`, import CloudFormation StackSet Instances that target AWS Organizational Units using the StackSet name, a slash (`/`) separated list of organizational unit IDs, and target AWS Region separated by commas (`,`). For example: * * ```sh * $ pulumi import aws:cloudformation/stackSetInstance:StackSetInstance example example,ou-sdas-123123123/ou-sdas-789789789,us-east-1 * ``` * Using `pulumi import`, import CloudFormation StackSet Instances when acting a delegated administrator in a member account using the StackSet name, target AWS account ID or slash (`/`) separated list of organizational unit IDs, target AWS Region and `call_as` value separated by commas (`,`). For example: * * ```sh * $ pulumi import aws:cloudformation/stackSetInstance:StackSetInstance example example,ou-sdas-123123123/ou-sdas-789789789,us-east-1,DELEGATED_ADMIN * ``` */ class StackSetInstance extends pulumi.CustomResource { /** * Get an existing StackSetInstance 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 StackSetInstance(name, state, { ...opts, id: id }); } /** * Returns true if the given object is an instance of StackSetInstance. 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'] === StackSetInstance.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["accountId"] = state?.accountId; resourceInputs["callAs"] = state?.callAs; resourceInputs["deploymentTargets"] = state?.deploymentTargets; resourceInputs["operationPreferences"] = state?.operationPreferences; resourceInputs["organizationalUnitId"] = state?.organizationalUnitId; resourceInputs["parameterOverrides"] = state?.parameterOverrides; resourceInputs["region"] = state?.region; resourceInputs["retainStack"] = state?.retainStack; resourceInputs["stackId"] = state?.stackId; resourceInputs["stackInstanceSummaries"] = state?.stackInstanceSummaries; resourceInputs["stackSetInstanceRegion"] = state?.stackSetInstanceRegion; resourceInputs["stackSetName"] = state?.stackSetName; } else { const args = argsOrState; if (args?.stackSetName === undefined && !opts.urn) { throw new Error("Missing required property 'stackSetName'"); } resourceInputs["accountId"] = args?.accountId; resourceInputs["callAs"] = args?.callAs; resourceInputs["deploymentTargets"] = args?.deploymentTargets; resourceInputs["operationPreferences"] = args?.operationPreferences; resourceInputs["parameterOverrides"] = args?.parameterOverrides; resourceInputs["region"] = args?.region; resourceInputs["retainStack"] = args?.retainStack; resourceInputs["stackSetInstanceRegion"] = args?.stackSetInstanceRegion; resourceInputs["stackSetName"] = args?.stackSetName; resourceInputs["organizationalUnitId"] = undefined /*out*/; resourceInputs["stackId"] = undefined /*out*/; resourceInputs["stackInstanceSummaries"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(StackSetInstance.__pulumiType, name, resourceInputs, opts); } } exports.StackSetInstance = StackSetInstance; /** @internal */ StackSetInstance.__pulumiType = 'aws:cloudformation/stackSetInstance:StackSetInstance'; //# sourceMappingURL=stackSetInstance.js.map