Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws_cloudformation_stackset: adding new accounts doesn't create new stack instances #1608

Closed
1 task done
Razique opened this issue Nov 30, 2022 · 4 comments · Fixed by #1790
Closed
1 task done

aws_cloudformation_stackset: adding new accounts doesn't create new stack instances #1608

Razique opened this issue Nov 30, 2022 · 4 comments · Fixed by #1790
Labels
bug This issue/PR relates to a bug module module plugins plugin (any type) python3 waiting_on_contributor Needs help. Feel free to engage to get things unblocked

Comments

@Razique
Copy link
Contributor

Razique commented Nov 30, 2022

Summary

Hi,
I have noticed that the cloudformation_stack_set module doesn't seem to support adding new accounts.
The stack set is initially provisioned with a list of accounts, however, on subsequent runs that have more accounts, the module doesn't add these new accounts.

Issue Type

Bug Report

Component Name

cloudformation_stack_set

Ansible Version

ansible 2.10.17
  config file = None
  configured module search path = ['/home/rmahroua/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.9/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.9.13 (main, May 18 2022, 00:00:00) [GCC 11.3.1 20220421 (Red Hat 11.3.1-2)]

Collection Versions

Collection    Version
------------- -------
amazon.aws    5.0.2  
awx.awx       21.7.0 
community.aws 5.0.0  

# /usr/local/lib/python3.9/site-packages/ansible_collections
Collection                    Version
----------------------------- -------
amazon.aws                    1.5.0  

AWS SDK versions

Name: boto
Version: 2.49.0
Summary: Amazon Web Services Library
Home-page: https://github.com/boto/boto/
Author: Mitch Garnaat
Author-email: [email protected]
License: MIT
Location: /home/rmahroua/.local/lib/python3.9/site-packages
Requires: 
Required-by: aws-automation
---
Name: boto3
Version: 1.24.89
Summary: The AWS SDK for Python
Home-page: https://github.com/boto/boto3
Author: Amazon Web Services
Author-email: 
License: Apache License 2.0
Location: /usr/local/lib/python3.9/site-packages
Requires: botocore, jmespath, s3transfer
Required-by: aws-automation, aws-shell
---
Name: botocore
Version: 1.27.89
Summary: Low-level, data-driven core of boto 3.
Home-page: https://github.com/boto/botocore
Author: Amazon Web Services
Author-email: 
License: Apache License 2.0
Location: /usr/local/lib/python3.9/site-packages
Requires: jmespath, python-dateutil, urllib3
Required-by: aws-automation, awscli, boto3, s3transfer

Configuration

$ ansible-config dump --only-changed

OS / Environment

Fedora release 34

Steps to Reproduce

# First run to deploy the stack set in two accounts
- name: Deploy AWS Config StackSet
  community.aws.cloudformation_stack_set:
    name: "My StackSet"
    description: "descripion"
    state: present
    template: "{{ stackset.config.template | default(omit) }}"
    accounts: [1234, 5678]
    region: us-east-1
    regions: us-east-1    

# Second run with an extra account
- name: Deploy AWS Config StackSet
  community.aws.cloudformation_stack_set:
    name: "My StackSet"
    description: "descripion"
    state: present
    template: "{{ stackset.config.template | default(omit) }}"
    accounts: [1234, 5678, 910112]
    region: us-east-1
    regions: us-east-1

Expected Results

When adding an account to the accounts parameter, the module should deploy a new stack instance for that account.

Actual Results

Currently, the new account isn't being added.

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibullbot
Copy link

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibullbot
Copy link

@ansibullbot ansibullbot added bug This issue/PR relates to a bug module module needs_triage plugins plugin (any type) python3 labels Nov 30, 2022
@Razique
Copy link
Contributor Author

Razique commented Dec 1, 2022

Based on my understanding of the API, the update_stack_instances call does not deploy new stack instances, it only updates parameters against existing stack instances.

To support real idempotency in this case, supplementary calls to the create_stack_instances is necessary.
The method takes in as parameter the name of an existing stack set to provision a new instance in new accounts.

response = client.create_stack_instances(
    StackSetName='string',
    Accounts=[
        'string',
    ],
    DeploymentTargets={
        'Accounts': [
            'string',
        ],
        'AccountsUrl': 'string',
        'OrganizationalUnitIds': [
            'string',
        ],
        'AccountFilterType': 'NONE'|'INTERSECTION'|'DIFFERENCE'|'UNION'
    },
    Regions=[
        'string',
    ],
    ParameterOverrides=[
        {
            'ParameterKey': 'string',
            'ParameterValue': 'string',
            'UsePreviousValue': True|False,
            'ResolvedValue': 'string'
        },
    ],
    OperationPreferences={
        'RegionConcurrencyType': 'SEQUENTIAL'|'PARALLEL',
        'RegionOrder': [
            'string',
        ],
        'FailureToleranceCount': 123,
        'FailureTolerancePercentage': 123,
        'MaxConcurrentCount': 123,
        'MaxConcurrentPercentage': 123
    },
    OperationId='string',
    CallAs='SELF'|'DELEGATED_ADMIN'
)

EDIT: happy to work on implementing this functionality if we wish to support adding new accounts -- if the goal of the module is to remain close to the original CloudFormation feature that consists in updating existing accounts only, then a new Ansible module is required since the current collection does not have any module for provisioning new stack instances for an existing stackset.

@alinabuzachis
Copy link
Contributor

@Razique Thank you for reporting this. Feel free to open a PR to support this functionality.

@alinabuzachis alinabuzachis added waiting_on_contributor Needs help. Feel free to engage to get things unblocked and removed needs_triage labels Feb 2, 2023
rmahroua added a commit to rmahroua/community.aws that referenced this issue Apr 24, 2023
tremble pushed a commit to rmahroua/community.aws that referenced this issue May 5, 2023
softwarefactory-project-zuul bot pushed a commit that referenced this issue May 5, 2023
…ions against existing stacksets complete (#1790)

cloudformation_stack_set - Add a waiter to ensure that running operations against existing stacksets complete

SUMMARY
Add a waiter to ensure that running operations against existing stacksets complete. Current code would fail in cases where new instances need to be added since the previous update_stack_set(module, stack_params, cfn) would still be running.
Fixes #1608
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
cloudformation_stack_set
ADDITIONAL INFORMATION
I initially thought that the module was not idempotent since new instances wouldn't be added to my existing stack sets. Upon closer examination, the issue had to do with the fact that we had prior calls being made before adding new instances to existing stack sets:
raise error_class(parsed_response, operation_name)\nbotocore.errorfactory.OperationInProgressException: 
    An error occurred (OperationInProgressException) when calling the UpdateStackInstances operation:
    Another Operation on StackSet arn:aws:cloudformation:us-east-1:XXXXXX:stackset/aws-config-stackset:2bcb419a-f263-48ca-9fe0-cdef11fb59de is in progress
The error got triggered because of a missing waiter after this operation:
changed |= update_stack_set(module, stack_params, cfn)
This change add a waiter function after the update operation, which, in turn, ensure that the subsequent call to add stack instances to the stack set properly run.

Reviewed-by: Mark Chappell
patchback bot pushed a commit that referenced this issue May 5, 2023
…ions against existing stacksets complete (#1790)

cloudformation_stack_set - Add a waiter to ensure that running operations against existing stacksets complete

SUMMARY
Add a waiter to ensure that running operations against existing stacksets complete. Current code would fail in cases where new instances need to be added since the previous update_stack_set(module, stack_params, cfn) would still be running.
Fixes #1608
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
cloudformation_stack_set
ADDITIONAL INFORMATION
I initially thought that the module was not idempotent since new instances wouldn't be added to my existing stack sets. Upon closer examination, the issue had to do with the fact that we had prior calls being made before adding new instances to existing stack sets:
raise error_class(parsed_response, operation_name)\nbotocore.errorfactory.OperationInProgressException:
    An error occurred (OperationInProgressException) when calling the UpdateStackInstances operation:
    Another Operation on StackSet arn:aws:cloudformation:us-east-1:XXXXXX:stackset/aws-config-stackset:2bcb419a-f263-48ca-9fe0-cdef11fb59de is in progress
The error got triggered because of a missing waiter after this operation:
changed |= update_stack_set(module, stack_params, cfn)
This change add a waiter function after the update operation, which, in turn, ensure that the subsequent call to add stack instances to the stack set properly run.

Reviewed-by: Mark Chappell
(cherry picked from commit 2c91768)
softwarefactory-project-zuul bot pushed a commit that referenced this issue May 5, 2023
…ions against existing stacksets complete (#1790) (#1806)

[PR #1790/2c917689 backport][stable-5] cloudformation_stack_set - Add a waiter to ensure that running operations against existing stacksets complete

This is a backport of PR #1790 as merged into main (2c91768).
SUMMARY
Add a waiter to ensure that running operations against existing stacksets complete. Current code would fail in cases where new instances need to be added since the previous update_stack_set(module, stack_params, cfn) would still be running.
Fixes #1608
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
cloudformation_stack_set
ADDITIONAL INFORMATION
I initially thought that the module was not idempotent since new instances wouldn't be added to my existing stack sets. Upon closer examination, the issue had to do with the fact that we had prior calls being made before adding new instances to existing stack sets:
raise error_class(parsed_response, operation_name)\nbotocore.errorfactory.OperationInProgressException: 
    An error occurred (OperationInProgressException) when calling the UpdateStackInstances operation:
    Another Operation on StackSet arn:aws:cloudformation:us-east-1:XXXXXX:stackset/aws-config-stackset:2bcb419a-f263-48ca-9fe0-cdef11fb59de is in progress
The error got triggered because of a missing waiter after this operation:
changed |= update_stack_set(module, stack_params, cfn)
This change add a waiter function after the update operation, which, in turn, ensure that the subsequent call to add stack instances to the stack set properly run.

Reviewed-by: Mark Chappell
abikouo added a commit to abikouo/community.aws that referenced this issue Oct 24, 2023
…-collections#1608)

s3_object - allow recursive copy of all objects in S3 bucket

SUMMARY

Add support to copy recursively all objects from one bucket to another one, user can set prefix to limit the object to copy.
closes ansible-collections#1379

ISSUE TYPE


Feature Pull Request

COMPONENT NAME

s3_object

Reviewed-by: Helen Bailey <[email protected]>
Reviewed-by: Bikouo Aubin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug module module plugins plugin (any type) python3 waiting_on_contributor Needs help. Feel free to engage to get things unblocked
Projects
None yet
3 participants