How to use stack_set_name method in localstack

Best Python code snippet using localstack_python

stack_set_instance.py

Source:stack_set_instance.py Github

copy

Full Screen

...39 if retain_stack is not None:40 pulumi.set(__self__, "retain_stack", retain_stack)41 @property42 @pulumi.getter(name="stackSetName")43 def stack_set_name(self) -> pulumi.Input[str]:44 """45 Name of the StackSet.46 """47 return pulumi.get(self, "stack_set_name")48 @stack_set_name.setter49 def stack_set_name(self, value: pulumi.Input[str]):50 pulumi.set(self, "stack_set_name", value)51 @property52 @pulumi.getter(name="accountId")53 def account_id(self) -> Optional[pulumi.Input[str]]:54 """55 Target AWS Account ID to create a Stack based on the StackSet. Defaults to current account.56 """57 return pulumi.get(self, "account_id")58 @account_id.setter59 def account_id(self, value: Optional[pulumi.Input[str]]):60 pulumi.set(self, "account_id", value)61 @property62 @pulumi.getter(name="deploymentTargets")63 def deployment_targets(self) -> Optional[pulumi.Input['StackSetInstanceDeploymentTargetsArgs']]:64 """65 The AWS Organizations accounts to which StackSets deploys. StackSets doesn't deploy stack instances to the organization management account, even if the organization management account is in your organization or in an OU in your organization. Drift detection is not possible for this argument. See deployment_targets below.66 """67 return pulumi.get(self, "deployment_targets")68 @deployment_targets.setter69 def deployment_targets(self, value: Optional[pulumi.Input['StackSetInstanceDeploymentTargetsArgs']]):70 pulumi.set(self, "deployment_targets", value)71 @property72 @pulumi.getter(name="parameterOverrides")73 def parameter_overrides(self) -> Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]]:74 """75 Key-value map of input parameters to override from the StackSet for this Instance.76 """77 return pulumi.get(self, "parameter_overrides")78 @parameter_overrides.setter79 def parameter_overrides(self, value: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]]):80 pulumi.set(self, "parameter_overrides", value)81 @property82 @pulumi.getter83 def region(self) -> Optional[pulumi.Input[str]]:84 """85 Target AWS Region to create a Stack based on the StackSet. Defaults to current region.86 """87 return pulumi.get(self, "region")88 @region.setter89 def region(self, value: Optional[pulumi.Input[str]]):90 pulumi.set(self, "region", value)91 @property92 @pulumi.getter(name="retainStack")93 def retain_stack(self) -> Optional[pulumi.Input[bool]]:94 """95 During resource destroy, remove Instance from StackSet while keeping the Stack and its associated resources. Must be enabled in the state _before_ destroy operation to take effect. You cannot reassociate a retained Stack or add an existing, saved Stack to a new StackSet. Defaults to `false`.96 """97 return pulumi.get(self, "retain_stack")98 @retain_stack.setter99 def retain_stack(self, value: Optional[pulumi.Input[bool]]):100 pulumi.set(self, "retain_stack", value)101@pulumi.input_type102class _StackSetInstanceState:103 def __init__(__self__, *,104 account_id: Optional[pulumi.Input[str]] = None,105 deployment_targets: Optional[pulumi.Input['StackSetInstanceDeploymentTargetsArgs']] = None,106 organizational_unit_id: Optional[pulumi.Input[str]] = None,107 parameter_overrides: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,108 region: Optional[pulumi.Input[str]] = None,109 retain_stack: Optional[pulumi.Input[bool]] = None,110 stack_id: Optional[pulumi.Input[str]] = None,111 stack_set_name: Optional[pulumi.Input[str]] = None):112 """113 Input properties used for looking up and filtering StackSetInstance resources.114 :param pulumi.Input[str] account_id: Target AWS Account ID to create a Stack based on the StackSet. Defaults to current account.115 :param pulumi.Input['StackSetInstanceDeploymentTargetsArgs'] deployment_targets: The AWS Organizations accounts to which StackSets deploys. StackSets doesn't deploy stack instances to the organization management account, even if the organization management account is in your organization or in an OU in your organization. Drift detection is not possible for this argument. See deployment_targets below.116 :param pulumi.Input[str] organizational_unit_id: The organization root ID or organizational unit (OU) IDs specified for `deployment_targets`.117 :param pulumi.Input[Mapping[str, pulumi.Input[str]]] parameter_overrides: Key-value map of input parameters to override from the StackSet for this Instance.118 :param pulumi.Input[str] region: Target AWS Region to create a Stack based on the StackSet. Defaults to current region.119 :param pulumi.Input[bool] retain_stack: During resource destroy, remove Instance from StackSet while keeping the Stack and its associated resources. Must be enabled in the state _before_ destroy operation to take effect. You cannot reassociate a retained Stack or add an existing, saved Stack to a new StackSet. Defaults to `false`.120 :param pulumi.Input[str] stack_id: Stack identifier121 :param pulumi.Input[str] stack_set_name: Name of the StackSet.122 """123 if account_id is not None:124 pulumi.set(__self__, "account_id", account_id)125 if deployment_targets is not None:126 pulumi.set(__self__, "deployment_targets", deployment_targets)127 if organizational_unit_id is not None:128 pulumi.set(__self__, "organizational_unit_id", organizational_unit_id)129 if parameter_overrides is not None:130 pulumi.set(__self__, "parameter_overrides", parameter_overrides)131 if region is not None:132 pulumi.set(__self__, "region", region)133 if retain_stack is not None:134 pulumi.set(__self__, "retain_stack", retain_stack)135 if stack_id is not None:136 pulumi.set(__self__, "stack_id", stack_id)137 if stack_set_name is not None:138 pulumi.set(__self__, "stack_set_name", stack_set_name)139 @property140 @pulumi.getter(name="accountId")141 def account_id(self) -> Optional[pulumi.Input[str]]:142 """143 Target AWS Account ID to create a Stack based on the StackSet. Defaults to current account.144 """145 return pulumi.get(self, "account_id")146 @account_id.setter147 def account_id(self, value: Optional[pulumi.Input[str]]):148 pulumi.set(self, "account_id", value)149 @property150 @pulumi.getter(name="deploymentTargets")151 def deployment_targets(self) -> Optional[pulumi.Input['StackSetInstanceDeploymentTargetsArgs']]:152 """153 The AWS Organizations accounts to which StackSets deploys. StackSets doesn't deploy stack instances to the organization management account, even if the organization management account is in your organization or in an OU in your organization. Drift detection is not possible for this argument. See deployment_targets below.154 """155 return pulumi.get(self, "deployment_targets")156 @deployment_targets.setter157 def deployment_targets(self, value: Optional[pulumi.Input['StackSetInstanceDeploymentTargetsArgs']]):158 pulumi.set(self, "deployment_targets", value)159 @property160 @pulumi.getter(name="organizationalUnitId")161 def organizational_unit_id(self) -> Optional[pulumi.Input[str]]:162 """163 The organization root ID or organizational unit (OU) IDs specified for `deployment_targets`.164 """165 return pulumi.get(self, "organizational_unit_id")166 @organizational_unit_id.setter167 def organizational_unit_id(self, value: Optional[pulumi.Input[str]]):168 pulumi.set(self, "organizational_unit_id", value)169 @property170 @pulumi.getter(name="parameterOverrides")171 def parameter_overrides(self) -> Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]]:172 """173 Key-value map of input parameters to override from the StackSet for this Instance.174 """175 return pulumi.get(self, "parameter_overrides")176 @parameter_overrides.setter177 def parameter_overrides(self, value: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]]):178 pulumi.set(self, "parameter_overrides", value)179 @property180 @pulumi.getter181 def region(self) -> Optional[pulumi.Input[str]]:182 """183 Target AWS Region to create a Stack based on the StackSet. Defaults to current region.184 """185 return pulumi.get(self, "region")186 @region.setter187 def region(self, value: Optional[pulumi.Input[str]]):188 pulumi.set(self, "region", value)189 @property190 @pulumi.getter(name="retainStack")191 def retain_stack(self) -> Optional[pulumi.Input[bool]]:192 """193 During resource destroy, remove Instance from StackSet while keeping the Stack and its associated resources. Must be enabled in the state _before_ destroy operation to take effect. You cannot reassociate a retained Stack or add an existing, saved Stack to a new StackSet. Defaults to `false`.194 """195 return pulumi.get(self, "retain_stack")196 @retain_stack.setter197 def retain_stack(self, value: Optional[pulumi.Input[bool]]):198 pulumi.set(self, "retain_stack", value)199 @property200 @pulumi.getter(name="stackId")201 def stack_id(self) -> Optional[pulumi.Input[str]]:202 """203 Stack identifier204 """205 return pulumi.get(self, "stack_id")206 @stack_id.setter207 def stack_id(self, value: Optional[pulumi.Input[str]]):208 pulumi.set(self, "stack_id", value)209 @property210 @pulumi.getter(name="stackSetName")211 def stack_set_name(self) -> Optional[pulumi.Input[str]]:212 """213 Name of the StackSet.214 """215 return pulumi.get(self, "stack_set_name")216 @stack_set_name.setter217 def stack_set_name(self, value: Optional[pulumi.Input[str]]):218 pulumi.set(self, "stack_set_name", value)219class StackSetInstance(pulumi.CustomResource):220 @overload221 def __init__(__self__,222 resource_name: str,223 opts: Optional[pulumi.ResourceOptions] = None,224 account_id: Optional[pulumi.Input[str]] = None,225 deployment_targets: Optional[pulumi.Input[pulumi.InputType['StackSetInstanceDeploymentTargetsArgs']]] = None,226 parameter_overrides: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,227 region: Optional[pulumi.Input[str]] = None,228 retain_stack: Optional[pulumi.Input[bool]] = None,229 stack_set_name: Optional[pulumi.Input[str]] = None,230 __props__=None):231 """232 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).233 > **NOTE:** All target accounts must have an IAM Role created that matches the name of the execution role configured in the StackSet (the `execution_role_name` argument in the `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.234 > **NOTE:** To retain the Stack during resource destroy, ensure `retain_stack` has been set to `true` in the state first. This must be completed _before_ a deployment that would destroy the resource.235 ## Example Usage236 ```python237 import pulumi238 import pulumi_aws as aws239 example = aws.cloudformation.StackSetInstance("example",240 account_id="123456789012",241 region="us-east-1",242 stack_set_name=aws_cloudformation_stack_set["example"]["name"])243 ```244 ### Example IAM Setup in Target Account245 ```python246 import pulumi247 import pulumi_aws as aws248 a_ws_cloud_formation_stack_set_execution_role_assume_role_policy = aws.iam.get_policy_document(statements=[aws.iam.GetPolicyDocumentStatementArgs(249 actions=["sts:AssumeRole"],250 effect="Allow",251 principals=[aws.iam.GetPolicyDocumentStatementPrincipalArgs(252 identifiers=[aws_iam_role["AWSCloudFormationStackSetAdministrationRole"]["arn"]],253 type="AWS",254 )],255 )])256 a_ws_cloud_formation_stack_set_execution_role = aws.iam.Role("aWSCloudFormationStackSetExecutionRole", assume_role_policy=a_ws_cloud_formation_stack_set_execution_role_assume_role_policy.json)257 a_ws_cloud_formation_stack_set_execution_role_minimum_execution_policy_policy_document = aws.iam.get_policy_document(statements=[aws.iam.GetPolicyDocumentStatementArgs(258 actions=[259 "cloudformation:*",260 "s3:*",261 "sns:*",262 ],263 effect="Allow",264 resources=["*"],265 )])266 a_ws_cloud_formation_stack_set_execution_role_minimum_execution_policy_role_policy = aws.iam.RolePolicy("aWSCloudFormationStackSetExecutionRoleMinimumExecutionPolicyRolePolicy",267 policy=a_ws_cloud_formation_stack_set_execution_role_minimum_execution_policy_policy_document.json,268 role=a_ws_cloud_formation_stack_set_execution_role.name)269 ```270 ### Example Deployment across Organizations account271 ```python272 import pulumi273 import pulumi_aws as aws274 example = aws.cloudformation.StackSetInstance("example",275 deployment_targets=aws.cloudformation.StackSetInstanceDeploymentTargetsArgs(276 organizational_unit_ids=[aws_organizations_organization["example"]["roots"][0]["id"]],277 ),278 region="us-east-1",279 stack_set_name=aws_cloudformation_stack_set["example"]["name"])280 ```281 ## Import282 CloudFormation StackSet Instances can be imported using the StackSet name, target AWS account ID, and target AWS region separated by commas (`,`) e.g.,283 ```sh284 $ pulumi import aws:cloudformation/stackSetInstance:StackSetInstance example example,123456789012,us-east-1285 ```286 :param str resource_name: The name of the resource.287 :param pulumi.ResourceOptions opts: Options for the resource.288 :param pulumi.Input[str] account_id: Target AWS Account ID to create a Stack based on the StackSet. Defaults to current account.289 :param pulumi.Input[pulumi.InputType['StackSetInstanceDeploymentTargetsArgs']] deployment_targets: The AWS Organizations accounts to which StackSets deploys. StackSets doesn't deploy stack instances to the organization management account, even if the organization management account is in your organization or in an OU in your organization. Drift detection is not possible for this argument. See deployment_targets below.290 :param pulumi.Input[Mapping[str, pulumi.Input[str]]] parameter_overrides: Key-value map of input parameters to override from the StackSet for this Instance.291 :param pulumi.Input[str] region: Target AWS Region to create a Stack based on the StackSet. Defaults to current region.292 :param pulumi.Input[bool] retain_stack: During resource destroy, remove Instance from StackSet while keeping the Stack and its associated resources. Must be enabled in the state _before_ destroy operation to take effect. You cannot reassociate a retained Stack or add an existing, saved Stack to a new StackSet. Defaults to `false`.293 :param pulumi.Input[str] stack_set_name: Name of the StackSet.294 """295 ...296 @overload297 def __init__(__self__,298 resource_name: str,299 args: StackSetInstanceArgs,300 opts: Optional[pulumi.ResourceOptions] = None):301 """302 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).303 > **NOTE:** All target accounts must have an IAM Role created that matches the name of the execution role configured in the StackSet (the `execution_role_name` argument in the `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.304 > **NOTE:** To retain the Stack during resource destroy, ensure `retain_stack` has been set to `true` in the state first. This must be completed _before_ a deployment that would destroy the resource.305 ## Example Usage306 ```python307 import pulumi308 import pulumi_aws as aws309 example = aws.cloudformation.StackSetInstance("example",310 account_id="123456789012",311 region="us-east-1",312 stack_set_name=aws_cloudformation_stack_set["example"]["name"])313 ```314 ### Example IAM Setup in Target Account315 ```python316 import pulumi317 import pulumi_aws as aws318 a_ws_cloud_formation_stack_set_execution_role_assume_role_policy = aws.iam.get_policy_document(statements=[aws.iam.GetPolicyDocumentStatementArgs(319 actions=["sts:AssumeRole"],320 effect="Allow",321 principals=[aws.iam.GetPolicyDocumentStatementPrincipalArgs(322 identifiers=[aws_iam_role["AWSCloudFormationStackSetAdministrationRole"]["arn"]],323 type="AWS",324 )],325 )])326 a_ws_cloud_formation_stack_set_execution_role = aws.iam.Role("aWSCloudFormationStackSetExecutionRole", assume_role_policy=a_ws_cloud_formation_stack_set_execution_role_assume_role_policy.json)327 a_ws_cloud_formation_stack_set_execution_role_minimum_execution_policy_policy_document = aws.iam.get_policy_document(statements=[aws.iam.GetPolicyDocumentStatementArgs(328 actions=[329 "cloudformation:*",330 "s3:*",331 "sns:*",332 ],333 effect="Allow",334 resources=["*"],335 )])336 a_ws_cloud_formation_stack_set_execution_role_minimum_execution_policy_role_policy = aws.iam.RolePolicy("aWSCloudFormationStackSetExecutionRoleMinimumExecutionPolicyRolePolicy",337 policy=a_ws_cloud_formation_stack_set_execution_role_minimum_execution_policy_policy_document.json,338 role=a_ws_cloud_formation_stack_set_execution_role.name)339 ```340 ### Example Deployment across Organizations account341 ```python342 import pulumi343 import pulumi_aws as aws344 example = aws.cloudformation.StackSetInstance("example",345 deployment_targets=aws.cloudformation.StackSetInstanceDeploymentTargetsArgs(346 organizational_unit_ids=[aws_organizations_organization["example"]["roots"][0]["id"]],347 ),348 region="us-east-1",349 stack_set_name=aws_cloudformation_stack_set["example"]["name"])350 ```351 ## Import352 CloudFormation StackSet Instances can be imported using the StackSet name, target AWS account ID, and target AWS region separated by commas (`,`) e.g.,353 ```sh354 $ pulumi import aws:cloudformation/stackSetInstance:StackSetInstance example example,123456789012,us-east-1355 ```356 :param str resource_name: The name of the resource.357 :param StackSetInstanceArgs args: The arguments to use to populate this resource's properties.358 :param pulumi.ResourceOptions opts: Options for the resource.359 """360 ...361 def __init__(__self__, resource_name: str, *args, **kwargs):362 resource_args, opts = _utilities.get_resource_args_opts(StackSetInstanceArgs, pulumi.ResourceOptions, *args, **kwargs)363 if resource_args is not None:364 __self__._internal_init(resource_name, opts, **resource_args.__dict__)365 else:366 __self__._internal_init(resource_name, *args, **kwargs)367 def _internal_init(__self__,368 resource_name: str,369 opts: Optional[pulumi.ResourceOptions] = None,370 account_id: Optional[pulumi.Input[str]] = None,371 deployment_targets: Optional[pulumi.Input[pulumi.InputType['StackSetInstanceDeploymentTargetsArgs']]] = None,372 parameter_overrides: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,373 region: Optional[pulumi.Input[str]] = None,374 retain_stack: Optional[pulumi.Input[bool]] = None,375 stack_set_name: Optional[pulumi.Input[str]] = None,376 __props__=None):377 if opts is None:378 opts = pulumi.ResourceOptions()379 if not isinstance(opts, pulumi.ResourceOptions):380 raise TypeError('Expected resource options to be a ResourceOptions instance')381 if opts.version is None:382 opts.version = _utilities.get_version()383 if opts.id is None:384 if __props__ is not None:385 raise TypeError('__props__ is only valid when passed in combination with a valid opts.id to get an existing resource')386 __props__ = StackSetInstanceArgs.__new__(StackSetInstanceArgs)387 __props__.__dict__["account_id"] = account_id388 __props__.__dict__["deployment_targets"] = deployment_targets389 __props__.__dict__["parameter_overrides"] = parameter_overrides390 __props__.__dict__["region"] = region391 __props__.__dict__["retain_stack"] = retain_stack392 if stack_set_name is None and not opts.urn:393 raise TypeError("Missing required property 'stack_set_name'")394 __props__.__dict__["stack_set_name"] = stack_set_name395 __props__.__dict__["organizational_unit_id"] = None396 __props__.__dict__["stack_id"] = None397 super(StackSetInstance, __self__).__init__(398 'aws:cloudformation/stackSetInstance:StackSetInstance',399 resource_name,400 __props__,401 opts)402 @staticmethod403 def get(resource_name: str,404 id: pulumi.Input[str],405 opts: Optional[pulumi.ResourceOptions] = None,406 account_id: Optional[pulumi.Input[str]] = None,407 deployment_targets: Optional[pulumi.Input[pulumi.InputType['StackSetInstanceDeploymentTargetsArgs']]] = None,408 organizational_unit_id: Optional[pulumi.Input[str]] = None,409 parameter_overrides: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,410 region: Optional[pulumi.Input[str]] = None,411 retain_stack: Optional[pulumi.Input[bool]] = None,412 stack_id: Optional[pulumi.Input[str]] = None,413 stack_set_name: Optional[pulumi.Input[str]] = None) -> 'StackSetInstance':414 """415 Get an existing StackSetInstance resource's state with the given name, id, and optional extra416 properties used to qualify the lookup.417 :param str resource_name: The unique name of the resulting resource.418 :param pulumi.Input[str] id: The unique provider ID of the resource to lookup.419 :param pulumi.ResourceOptions opts: Options for the resource.420 :param pulumi.Input[str] account_id: Target AWS Account ID to create a Stack based on the StackSet. Defaults to current account.421 :param pulumi.Input[pulumi.InputType['StackSetInstanceDeploymentTargetsArgs']] deployment_targets: The AWS Organizations accounts to which StackSets deploys. StackSets doesn't deploy stack instances to the organization management account, even if the organization management account is in your organization or in an OU in your organization. Drift detection is not possible for this argument. See deployment_targets below.422 :param pulumi.Input[str] organizational_unit_id: The organization root ID or organizational unit (OU) IDs specified for `deployment_targets`.423 :param pulumi.Input[Mapping[str, pulumi.Input[str]]] parameter_overrides: Key-value map of input parameters to override from the StackSet for this Instance.424 :param pulumi.Input[str] region: Target AWS Region to create a Stack based on the StackSet. Defaults to current region.425 :param pulumi.Input[bool] retain_stack: During resource destroy, remove Instance from StackSet while keeping the Stack and its associated resources. Must be enabled in the state _before_ destroy operation to take effect. You cannot reassociate a retained Stack or add an existing, saved Stack to a new StackSet. Defaults to `false`.426 :param pulumi.Input[str] stack_id: Stack identifier427 :param pulumi.Input[str] stack_set_name: Name of the StackSet.428 """429 opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))430 __props__ = _StackSetInstanceState.__new__(_StackSetInstanceState)431 __props__.__dict__["account_id"] = account_id432 __props__.__dict__["deployment_targets"] = deployment_targets433 __props__.__dict__["organizational_unit_id"] = organizational_unit_id434 __props__.__dict__["parameter_overrides"] = parameter_overrides435 __props__.__dict__["region"] = region436 __props__.__dict__["retain_stack"] = retain_stack437 __props__.__dict__["stack_id"] = stack_id438 __props__.__dict__["stack_set_name"] = stack_set_name439 return StackSetInstance(resource_name, opts=opts, __props__=__props__)440 @property441 @pulumi.getter(name="accountId")442 def account_id(self) -> pulumi.Output[str]:443 """444 Target AWS Account ID to create a Stack based on the StackSet. Defaults to current account.445 """446 return pulumi.get(self, "account_id")447 @property448 @pulumi.getter(name="deploymentTargets")449 def deployment_targets(self) -> pulumi.Output[Optional['outputs.StackSetInstanceDeploymentTargets']]:450 """451 The AWS Organizations accounts to which StackSets deploys. StackSets doesn't deploy stack instances to the organization management account, even if the organization management account is in your organization or in an OU in your organization. Drift detection is not possible for this argument. See deployment_targets below.452 """453 return pulumi.get(self, "deployment_targets")454 @property455 @pulumi.getter(name="organizationalUnitId")456 def organizational_unit_id(self) -> pulumi.Output[str]:457 """458 The organization root ID or organizational unit (OU) IDs specified for `deployment_targets`.459 """460 return pulumi.get(self, "organizational_unit_id")461 @property462 @pulumi.getter(name="parameterOverrides")463 def parameter_overrides(self) -> pulumi.Output[Optional[Mapping[str, str]]]:464 """465 Key-value map of input parameters to override from the StackSet for this Instance.466 """467 return pulumi.get(self, "parameter_overrides")468 @property469 @pulumi.getter470 def region(self) -> pulumi.Output[str]:471 """472 Target AWS Region to create a Stack based on the StackSet. Defaults to current region.473 """474 return pulumi.get(self, "region")475 @property476 @pulumi.getter(name="retainStack")477 def retain_stack(self) -> pulumi.Output[Optional[bool]]:478 """479 During resource destroy, remove Instance from StackSet while keeping the Stack and its associated resources. Must be enabled in the state _before_ destroy operation to take effect. You cannot reassociate a retained Stack or add an existing, saved Stack to a new StackSet. Defaults to `false`.480 """481 return pulumi.get(self, "retain_stack")482 @property483 @pulumi.getter(name="stackId")484 def stack_id(self) -> pulumi.Output[str]:485 """486 Stack identifier487 """488 return pulumi.get(self, "stack_id")489 @property490 @pulumi.getter(name="stackSetName")491 def stack_set_name(self) -> pulumi.Output[str]:492 """493 Name of the StackSet.494 """...

Full Screen

Full Screen

cloudformation.py

Source:cloudformation.py Github

copy

Full Screen

1######################################################################################################################2# Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. #3# #4# Licensed under the Amazon Software License (the "License"). You may not use this file except in compliance #5# with the License. A copy of the License is located at #6# #7# http://aws.amazon.com/asl/ #8# #9# or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES #10# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions #11# and limitations under the License. #12######################################################################################################################13#!/bin/python14import boto315import inspect16from botocore.exceptions import ClientError17cfn_client = boto3.client('cloudformation')18class StackSet(object):19 def __init__(self, logger):20 self.logger = logger21 def describe_stack_set(self, stack_set_name):22 try:23 response = cfn_client.describe_stack_set(24 StackSetName=stack_set_name25 )26 return response27 except Exception:28 pass29 def describe_stack_set_operation(self, stack_set_name, operation_id):30 try:31 response = cfn_client.describe_stack_set_operation(32 StackSetName=stack_set_name,33 OperationId=operation_id34 )35 return response36 except Exception as e:37 self.logger.error("'{}' StackSet Operation ID: {} not found.".format(stack_set_name, operation_id))38 message = {'FILE': __file__.split('/')[-1], 'CLASS': self.__class__.__name__,39 'METHOD': inspect.stack()[0][3], 'EXCEPTION': str(e)}40 self.logger.exception(message)41 raise42 def list_stack_instances(self, **kwargs):43 try:44 response = cfn_client.list_stack_instances(**kwargs)45 return response46 except Exception as e:47 message = {'FILE': __file__.split('/')[-1], 'CLASS': self.__class__.__name__,48 'METHOD': inspect.stack()[0][3], 'EXCEPTION': str(e)}49 self.logger.exception(message)50 raise51 def create_stack_set(self, stack_set_name, template_url, cf_params, capabilities):52 try:53 parameters = []54 d = {}55 for key, value in cf_params.items():56 '''This condition checks if the value is a List and convert it into a Comma-delimited string.57 Note: Remember to change the parameter type from 'List<AWS::EC2::*::*>'58 (Supported AWS-Specific Parameter Types) to 'CommaDelimitedList' in the template.'''59 if type(value) == list:60 value = ",".join(map(str, value))61 self.logger.debug("CF Parameter Key: {}, CF Parameter Value: {}".format(key, value))62 d['ParameterKey'] = key63 d['ParameterValue'] = value64 parameters.append(d.copy())65 response = cfn_client.create_stack_set(66 StackSetName=stack_set_name,67 TemplateURL=template_url,68 Parameters=parameters,69 Capabilities=[capabilities],70 Tags=[71 {72 'Key': 'AWS_Solutions',73 'Value': 'LandingZoneStackSet'74 },75 ]76 )77 return response78 except Exception as e:79 message = {'FILE': __file__.split('/')[-1], 'CLASS': self.__class__.__name__,80 'METHOD': inspect.stack()[0][3], 'EXCEPTION': str(e)}81 self.logger.exception(message)82 raise83 def create_stack_instances(self, stack_set_name, account_list, region_list,84 failed_tolerance_percent=50, max_concurrent_percent=100):85 try:86 response = cfn_client.create_stack_instances(87 StackSetName=stack_set_name,88 Accounts=account_list,89 Regions=region_list,90 OperationPreferences={91 'FailureTolerancePercentage': failed_tolerance_percent,92 'MaxConcurrentPercentage': max_concurrent_percent93 }94 )95 return response96 except ClientError as e:97 if e.response['Error']['Code'] == 'OperationInProgressException':98 self.logger.info("Caught exception 'OperationInProgressException', handling the exception...")99 return {"OperationId": "OperationInProgressException"}100 else:101 message = {'FILE': __file__.split('/')[-1], 'CLASS': self.__class__.__name__,102 'METHOD': inspect.stack()[0][3], 'EXCEPTION': str(e)}103 self.logger.exception(message)104 raise105 def create_stack_instances_with_override_params(self, stack_set_name, account_list, region_list, override_params,106 failed_tolerance_percent=50, max_concurrent_percent=100):107 try:108 parameters = []109 d = {}110 for key, value in override_params.items():111 '''This condition checks if the value is a List and convert it into a Comma-delimited string.112 Note: Remember to change the parameter type from 'List<AWS::EC2::*::*>'113 (Supported AWS-Specific Parameter Types) to 'CommaDelimitedList' in the template.'''114 if type(value) == list:115 value = ",".join(map(str, value))116 self.logger.debug("CF Parameter Key: {}, CF Parameter Value: {}".format(key, value))117 d['ParameterKey'] = key118 d['ParameterValue'] = value119 parameters.append(d.copy())120 response = cfn_client.create_stack_instances(121 StackSetName=stack_set_name,122 Accounts=account_list,123 Regions=region_list,124 ParameterOverrides=parameters,125 OperationPreferences={126 'FailureTolerancePercentage': failed_tolerance_percent,127 'MaxConcurrentPercentage': max_concurrent_percent128 }129 )130 return response131 except ClientError as e:132 if e.response['Error']['Code'] == 'OperationInProgressException':133 self.logger.info("Caught exception 'OperationInProgressException', handling the exception...")134 return {"OperationId": "OperationInProgressException"}135 else:136 message = {'FILE': __file__.split('/')[-1], 'CLASS': self.__class__.__name__,137 'METHOD': inspect.stack()[0][3], 'EXCEPTION': str(e)}138 self.logger.exception(message)139 raise140 def update_stack_instances(self, stack_set_name, account_list, region_list, override_params,141 failed_tolerance_percent=50, max_concurrent_percent=100):142 try:143 parameters = []144 d = {}145 for key, value in override_params.items():146 '''This condition checks if the value is a List and convert it into a Comma-delimited string.147 Note: Remember to change the parameter type from 'List<AWS::EC2::*::*>'148 (Supported AWS-Specific Parameter Types) to 'CommaDelimitedList' in the template.'''149 if type(value) == list:150 value = ",".join(map(str, value))151 self.logger.debug("CF Parameter Key: {}, CF Parameter Value: {}".format(key, value))152 d['ParameterKey'] = key153 d['ParameterValue'] = value154 parameters.append(d.copy())155 response = cfn_client.update_stack_instances(156 StackSetName=stack_set_name,157 Accounts=account_list,158 Regions=region_list,159 ParameterOverrides=parameters,160 OperationPreferences={161 'FailureTolerancePercentage': failed_tolerance_percent,162 'MaxConcurrentPercentage': max_concurrent_percent163 }164 )165 return response166 except ClientError as e:167 if e.response['Error']['Code'] == 'OperationInProgressException':168 self.logger.info("Caught exception 'OperationInProgressException', handling the exception...")169 return {"OperationId": "OperationInProgressException"}170 else:171 message = {'FILE': __file__.split('/')[-1], 'CLASS': self.__class__.__name__,172 'METHOD': inspect.stack()[0][3], 'EXCEPTION': str(e)}173 self.logger.exception(message)174 raise175 def update_stack_set(self, stack_set_name, parameter, template_url, capabilities, failed_tolerance_percent=50,176 max_concurrent_percent=100):177 try:178 parameters = []179 d = {}180 for key, value in parameter.items():181 '''This condition checks if the value is a List and convert it into a Comma-delimited string.182 Note: Remember to change the parameter type from 'List<AWS::EC2::*::*>'183 (Supported AWS-Specific Parameter Types) to 'CommaDelimitedList' in the template.'''184 if type(value) == list:185 value = ",".join(map(str, value))186 self.logger.debug("CF Parameter Key: {}, CF Parameter Value: {}".format(key, value))187 d['ParameterKey'] = key188 d['ParameterValue'] = value189 parameters.append(d.copy())190 response = cfn_client.update_stack_set(191 StackSetName=stack_set_name,192 TemplateURL=template_url,193 Parameters=parameters,194 Capabilities=[capabilities],195 OperationPreferences={196 'FailureTolerancePercentage': failed_tolerance_percent,197 'MaxConcurrentPercentage': max_concurrent_percent198 }199 )200 return response201 except ClientError as e:202 if e.response['Error']['Code'] == 'OperationInProgressException':203 self.logger.info("Caught exception 'OperationInProgressException', handling the exception...")204 return {"OperationId": "OperationInProgressException"}205 else:206 message = {'FILE': __file__.split('/')[-1], 'CLASS': self.__class__.__name__,207 'METHOD': inspect.stack()[0][3], 'EXCEPTION': str(e)}208 self.logger.exception(message)209 raise210 def delete_stack_set(self, stack_set_name):211 try:212 response = cfn_client.delete_stack_set(213 StackSetName=stack_set_name,214 )215 return response216 except Exception as e:217 message = {'FILE': __file__.split('/')[-1], 'CLASS': self.__class__.__name__,218 'METHOD': inspect.stack()[0][3], 'EXCEPTION': str(e)}219 self.logger.exception(message)220 raise221 def delete_stack_instances(self, stack_set_name, account_list, region_list, retain_condition=False,222 failed_tolerance_percent=50, max_concurrent_percent=100):223 try:224 response = cfn_client.delete_stack_instances(225 StackSetName=stack_set_name,226 Accounts=account_list,227 Regions=region_list,228 RetainStacks=retain_condition,229 OperationPreferences={230 'FailureTolerancePercentage': failed_tolerance_percent,231 'MaxConcurrentPercentage': max_concurrent_percent232 }233 )234 return response235 except ClientError as e:236 if e.response['Error']['Code'] == 'OperationInProgressException':237 self.logger.info("Caught exception 'OperationInProgressException', handling the exception...")238 return {"OperationId": "OperationInProgressException"}239 else:240 message = {'FILE': __file__.split('/')[-1], 'CLASS': self.__class__.__name__,241 'METHOD': inspect.stack()[0][3], 'EXCEPTION': str(e)}242 self.logger.exception(message)243 raise244 def describe_stack_instance(self, stack_set_name, account_id, region):245 try:246 response = cfn_client.describe_stack_instance(247 StackSetName=stack_set_name,248 StackInstanceAccount=account_id,249 StackInstanceRegion=region250 )251 return response252 except Exception as e:253 message = {'FILE': __file__.split('/')[-1], 'CLASS': self.__class__.__name__,254 'METHOD': inspect.stack()[0][3], 'EXCEPTION': str(e)}255 self.logger.exception(message)256 raise257class Stacks(object):258 def __init__(self, logger, **kwargs):259 self.logger = logger260 if kwargs is not None:261 if kwargs.get('credentials') is None:262 logger.debug("Setting up CFN BOTO3 Client with default credentials")263 self.cfn_client = boto3.client('cloudformation')264 else:265 logger.debug("Setting up CFN BOTO3 Client with ASSUMED ROLE credentials")266 cred = kwargs.get('credentials')267 region = kwargs.get('region', None)268 if region:269 self.cfn_client = boto3.client('cloudformation', region_name=region,270 aws_access_key_id=cred.get('AccessKeyId'),271 aws_secret_access_key=cred.get('SecretAccessKey'),272 aws_session_token=cred.get('SessionToken')273 )274 else:275 self.cfn_client = boto3.client('cloudformation',276 aws_access_key_id=cred.get('AccessKeyId'),277 aws_secret_access_key=cred.get('SecretAccessKey'),278 aws_session_token=cred.get('SessionToken')279 )280 def describe_stacks(self, stack_name):281 try:282 response = self.cfn_client.describe_stacks(283 StackName=stack_name284 )285 return response286 except Exception as e:287 message = {'FILE': __file__.split('/')[-1], 'CLASS': self.__class__.__name__,288 'METHOD': inspect.stack()[0][3], 'EXCEPTION': str(e)}289 self.logger.exception(message)...

Full Screen

Full Screen

stack.py

Source:stack.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2from .pkg.fingerprint import fingerprint3def upload_cf_template(boto_ses,4 template_content,5 bucket_name,6 prefix,7 format_is_json=True):8 """9 Upload cloudformation template to s3 bucket and returns template url.10 :type boto_ses:11 :type template_content: str12 :type bucket_name: str13 :type prefix: str14 :type format_is_json: bool15 :rtype: str16 """17 s3_client = boto_ses.client("s3")18 fname = fingerprint.of_text(template_content)19 if prefix.endswith("/"):20 prefix = prefix[:-1]21 if format_is_json:22 ext = "json"23 else:24 ext = "yml"25 s3_key = "{}/{}.{}".format(prefix, fname, ext)26 s3_client.put_object(27 Body=template_content,28 Bucket=bucket_name,29 Key=s3_key,30 )31 template_url = "https://s3.amazonaws.com/{}/{}".format(bucket_name, s3_key)32 return template_url33def deploy_stack(boto_ses,34 stack_name,35 template_url,36 stack_tags,37 stack_parameters,38 execution_role_arn=None):39 cf_client = boto_ses.client("cloudformation")40 try:41 res = cf_client.describe_stacks(42 StackName=stack_name43 )44 if len(res["Stacks"]) == 1:45 stack_exists_flag = True46 else:47 stack_exists_flag = False48 except:49 stack_exists_flag = False50 if stack_exists_flag is True:51 res = cf_client.update_stack(52 StackName=stack_name,53 TemplateURL=template_url,54 Parameters=stack_parameters,55 Capabilities=[56 "CAPABILITY_NAMED_IAM",57 ],58 # RoleARN=execution_role_arn,59 Tags=stack_tags,60 )61 else:62 res = cf_client.create_stack(63 StackName=stack_name,64 TemplateURL=template_url,65 Parameters=stack_parameters,66 Capabilities=[67 "CAPABILITY_NAMED_IAM",68 ],69 # RoleARN=execution_role_arn,70 )71 return res72def deploy_stack_set(boto_ses,73 stack_set_name,74 template_url,75 stack_tags,76 stack_parameters,77 stack_set_admin_role,78 accounts,79 regions):80 cf_client = boto_ses.client("cloudformation")81 try:82 res_describe_stack_set = cf_client.describe_stack_set(83 StackSetName=stack_set_name84 )85 if res_describe_stack_set["StackSet"]["StackSetName"] == stack_set_name:86 stack_set_exists_flag = True87 else:88 stack_set_exists_flag = False89 except:90 stack_set_exists_flag = False91 if stack_set_exists_flag is False:92 res_create_stack_set = cf_client.create_stack_set(93 StackSetName=stack_set_name,94 TemplateURL=template_url,95 Parameters=stack_parameters,96 Tags=stack_tags,97 Capabilities=[98 "CAPABILITY_NAMED_IAM",99 ],100 AdministrationRoleARN=stack_set_admin_role,101 ExecutionRoleName="AWSCloudFormationStackSetExecutionRole",102 )103 res_list_stack_instances = cf_client.list_stack_instances(104 StackSetName=stack_set_name105 )106 if len(res_list_stack_instances["Summaries"]) == 0:107 has_stack_set_instance_flag = False108 else:109 has_stack_set_instance_flag = True110 if has_stack_set_instance_flag:111 res_update_stack_set = cf_client.update_stack_set(112 StackSetName=stack_set_name,113 TemplateURL=template_url,114 Parameters=stack_parameters,115 Capabilities=[116 "CAPABILITY_NAMED_IAM",117 ],118 AdministrationRoleARN=stack_set_admin_role,119 ExecutionRoleName="AWSCloudFormationStackSetExecutionRole",120 Accounts=accounts,121 Regions=regions,122 )123 return res_update_stack_set124 else:125 res_create_stack_instances = cf_client.create_stack_instances(126 StackSetName=stack_set_name,127 Accounts=accounts,128 Regions=regions,129 ParameterOverrides=stack_parameters,130 )...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful