'Boto3 AttributeError: 'CloudFormation' object has no attribute 'import_stacks_to_stack_set'
Hello I am trying to import a number of stacks into a new stack set and I keep running into the above error(in title). I have tested to make sure my client was set up correctly by listing stacks with the list_stack_instances() function and this gave me the expected output. But every time I try and do an import I keep getting the same error. I have only seen this error when the client was not set up properly so im a little confused on how I can get this working. I have a list of stacks I would like to import to a new stackset here is my code:
from datetime import datetime
import boto3
import pyorgs
from botocore.exceptions import ClientError
import time
LEGACY_STACKSET_NAME = "aws-organization-resources-ArtifactBucket"
CUSTOM_STACKSET_NAME = "CustomControlTower-artifacts-s3-bucket"
def update_stacks(stackset_name, client, verified_cfn_list):
client = boto3.client('cloudformation')
for stack in verified_cfn_list:
print(f"Importing {stack}")
try:
response = client.import_stacks_to_stack_set(
StackSetName=stackset_name,
StackIds=[stack],
OperationPreferences={
'RegionConcurrencyType': 'SEQUENTIAL',
'RegionOrder': [
'us-east-1',
],
'FailureToleranceCount': 10,
'MaxConcurrentCount': 10,
},
CallAs='SELF',
)
status = "RUNNING"
while status == "RUNNING":
operation_response = client.describe_stack_set_operation(
StackSetName=stackset_name,
OperationId=response["OperationId"],
)
status = operation_response["StackSetOperation"]["Status"]
time.sleep(3)
print(status)
except ClientError as e:
print(f"Unable to Import Stack: {e}")
mylist = [
"arn:aws:cloudformation:ap-southeast-2:123456789123:stack/StackSet-aws-organization-resources-ArtifactBucket-d8c5fd85-ceb7-48a3-bfec-7178cbdd376b/a6426a30-85b4-11eb-84b1-060d5ced2462",
"arn:aws:cloudformation:us-east-1:123456789123:stack/StackSet-aws-organization-resources-ArtifactBucket-d6a4cbde-3094-491e-8a87-1562eca9eb24/961b92f0-1abe-11eb-aa74-12bf92df32e3",
"arn:aws:cloudformation:us-east-2:123456789123:stack/StackSet-aws-organization-resources-ArtifactBucket-67d1ae21-f615-47d2-8016-6891dae15053/27f2f710-a38e-11eb-abcb-0a1409966064",
"arn:aws:cloudformation:ap-southeast-2:123456789123:stack/StackSet-aws-organization-resources-ArtifactBucket-1d91657c-cd18-4929-b7a2-14a04c8786f2/05809a40-c85d-11eb-8ed6-025033e0d360",
"arn:aws:cloudformation:us-east-1:123456789123:stack/StackSet-aws-organization-resources-ArtifactBucket-7f207cda-ebc1-40da-b6cd-69cb6a1fb300/1a55b3b0-c85d-11eb-9dd3-0e8a1126433d
]
def main():
client = boto3.client('cloudformation', region_name="ap-southeast-2")
stacks_from_s3 = mylist
update_stacks(CUSTOM_STACKSET_NAME,client, stacks_from_s3)
if __name__ == '__main__':
main()
could this have anything to do with region maybe?
pythonpython-3.xamazon-web-services">
amazon-web-servicesamazon-cloudformation">
amazon-cloudformationboto3
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
