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 deploy fails although deploy continues to run on AWS #2831

Open
jyrkiput opened this issue Sep 14, 2017 · 9 comments
Open
Labels
cloudformation package-deploy customization Issues related to CLI customizations (located in /awscli/customizations) feature-request A feature should be added or improved. p3 This is a minor priority issue

Comments

@jyrkiput
Copy link

We have embedded stack which takes a while to create. Comand "aws cloudformation deploy" fails with error code 255 and "Max attempts exceeded", although the stack continues to be created on AWS and eventually succeeds.

Version:

aws --version
aws-cli/1.11.148 Python/2.7.12+ Linux/4.10.0-35-generic botocore/1.7.6

Last lines of debug output are:

2017-09-14 11:03:04,807 - MainThread - botocore.hooks - DEBUG - Event needs-retry.cloudformation.DescribeStacks: calling handler <botocore.retryhandler.RetryHandler object at 0x7f4de3a36c10>
2017-09-14 11:03:04,808 - MainThread - botocore.retryhandler - DEBUG - No retry needed.
2017-09-14 11:03:04,809 - MainThread - awscli.customizations.cloudformation.deployer - DEBUG - Execute changeset waiter exception
Traceback (most recent call last):
  File "/home/jyrki/.virtualenvs/op-aws/local/lib/python2.7/site-packages/awscli/customizations/cloudformation/deployer.py", line 184, in wait_for_execute
    waiter.wait(StackName=stack_name)
  File "/home/jyrki/.virtualenvs/op-aws/local/lib/python2.7/site-packages/botocore/waiter.py", line 53, in wait
    Waiter.wait(self, **kwargs)
  File "/home/jyrki/.virtualenvs/op-aws/local/lib/python2.7/site-packages/botocore/waiter.py", line 329, in wait
    last_response=response
WaiterError: Waiter StackCreateComplete failed: Max attempts exceeded
2017-09-14 11:03:04,811 - MainThread - awscli.clidriver - DEBUG - Exception caught in main()
Traceback (most recent call last):
  File "/home/jyrki/.virtualenvs/op-aws/local/lib/python2.7/site-packages/awscli/clidriver.py", line 200, in main
    return command_table[parsed_args.command](remaining, parsed_args)
  File "/home/jyrki/.virtualenvs/op-aws/local/lib/python2.7/site-packages/awscli/clidriver.py", line 338, in __call__
    return command_table[parsed_args.operation](remaining, parsed_globals)
  File "/home/jyrki/.virtualenvs/op-aws/local/lib/python2.7/site-packages/awscli/customizations/commands.py", line 187, in __call__
    return self._run_main(parsed_args, parsed_globals)
  File "/home/jyrki/.virtualenvs/op-aws/local/lib/python2.7/site-packages/awscli/customizations/cloudformation/deploy.py", line 184, in _run_main
    parsed_args.notification_arns)
  File "/home/jyrki/.virtualenvs/op-aws/local/lib/python2.7/site-packages/awscli/customizations/cloudformation/deploy.py", line 199, in deploy
    deployer.wait_for_execute(stack_name, result.changeset_type)
  File "/home/jyrki/.virtualenvs/op-aws/local/lib/python2.7/site-packages/awscli/customizations/cloudformation/deployer.py", line 188, in wait_for_execute
    raise exceptions.DeployFailedError(stack_name=stack_name)
DeployFailedError: Failed to create/update the stack. Run the following command
to fetch the list of events leading up to the failure
aws cloudformation describe-stack-events --stack-name op-smooth-operator-development
2017-09-14 11:03:04,814 - MainThread - awscli.clidriver - DEBUG - Exiting with rc 255

I tried to look if it would be simple to increase maxAttempts in botocore, but that seemed to be pretty complicated.

Workaround for this is to check with aws cloudformation describe-stack if the stack really failed.

@cwgem
Copy link
Contributor

cwgem commented Sep 14, 2017

The value is actually here from what I can tell:

https://github.com/aws/aws-cli/blob/develop/awscli/customizations/cloudformation/deployer.py#L182

So you could potentially manually change that (default looks to be 3600 seconds or 1 hour). That said seems like this might be something that should be configurable ala AWS config file.

@jyrkiput
Copy link
Author

Thanks, that was added 6 days ago so I didn't have it yet. My builds take less than hour, around 5 minutes actually. So as far as I'm concerned, this has already been fixed 👍

@joguSD
Copy link
Contributor

joguSD commented Sep 14, 2017

Closing this out as the fix should already be out in v1.11.152!

@joguSD joguSD closed this as completed Sep 14, 2017
@nello
Copy link

nello commented May 3, 2018

This problem appears to be back in spades:

[2018-05-03T21:08:09Z] ++ aws elbv2 describe-target-groups --names ... --query 'TargetGroups[].TargetGroupArn' --output text
[2018-05-03T21:08:09Z] + aws elbv2 wait target-in-service --target-group-arn arn:aws:elasticloadbalancing:ap-southeast-2:..
[2018-05-03T21:17:57Z]
[2018-05-03T21:17:57Z] Waiter TargetInService failed: Max attempts exceeded
[2018-05-03T21:17:57Z] 🚨 Error: The command exited with status 255

@rfrad
Copy link

rfrad commented Sep 23, 2020

I faced the same issue when trying to deploy a conflicted serverless configuration.

The conflict occurred in the path defined in my template.yaml:

...
Resources:
  Profile:
    Type: AWS::Serverless::Function
    Properties:
      ...
      Events:
        CreateResource:
          Type: Api
          Properties:
            RestApiId: !Ref RestAPI
            Path: /resource/{token} # <= Here
            Method: post
        ConfirmResource:
          Type: Api
          Properties:
            RestApiId: !Ref RestAPI
            Path: /resource/{resourceId}/confirm # <= with there
            Method: post
...

The conflict is between the path parameter {token} and {resourceId}. Although both URLs are different, Cloud Formation doesn't seem to like the different names for a same path parameter. As soon as I changed the /resource/{resourceId}/confirm url to /resource/confirm/{resourceId}, it all got fixed.

@iRemjeyX
Copy link

Is there anyway to edit the waiter config without touching python code? (Like using an environment var or something?)

thoward-godaddy pushed a commit to thoward-godaddy/aws-cli that referenced this issue Feb 12, 2022
* sam pipeline bootstrap (aws#2811)

* two-stages-pipeline plugin

* typos

* add docstring

* make mypy happy

* removing swap file

* delete the two_stages_pipeline plugin as the pipeline-bootstrap command took over its responsibility

* remove 'get_template_function_runtimes' function as the decision is made to not process the SAM template during pipeline init which was the only place we use the function

* sam pipeline bootstrap command

* move the pipelineconfig.toml file to .aws-sam

* UX - rewriting

Co-authored-by: Chris Rehn <crehn@outlook.com>

* UX improvements

* make black happy

* apply review comments

* UX - rewriting

Co-authored-by: Chris Rehn <crehn@outlook.com>

* refactor

* Apply review comments

* use python way of array elements assignments

* Update samcli/lib/pipeline/bootstrap/stage.py

Co-authored-by: _sam <3804518+aahung@users.noreply.github.com>

* apply review comments

* typo

* read using utf-8

* create and user a safe version of the save_config method

* apply review comments

* rename _get_command_name to _get_command_names

* don't save generated ARNs for now, will save during init

* Revert "don't save generated ARNs for now, will save during init"

This reverts commit d184e164022d9560131c62a826436edbc93da189.

* Notify the user to rotate periodically rotate the IAM credentials

* typo

* Use AES instead of KMS for S3 SSE

* rename Ecr to ECR and Iam to IAM

* Grant lambda service explicit permissions to thhe ECR instead of relying on giving this permissions on ad-hoc while creating the container images

Co-authored-by: Chris Rehn <crehn@outlook.com>
Co-authored-by: _sam <3804518+aahung@users.noreply.github.com>

* sam pipeline init command (aws#2831)

* sam pipeline init command

* apply review comments

* apply review comments

* display a message that we have successfully created the pipeline configuration file(s).

* doc typo

* Let 'sam pipeline init'  prefills pipeline's infrastructure resources… (aws#2894)

* Let 'sam pipeline init'  prefills pipeline's infrastructure resources' values from 'sam pipeline bootstrap'  results.

* save bootstrapped sateg region

* make black happy

* exclude non-dict keys from samconfig.get_env_names method.

* Rename the pipeline 'Stage' concept to 'Environment' (aws#2908)

* Rename the pipeline 'Stage' concept to 'Environment'

* typo

* Rename --environment-name argument to --environment

* Sam pipelines ux rename ecr repo to image repository (aws#2910)

* Rename ecr-repo to image-repository

* UT Fixes

* typo

* typo

* feat: Support creating pipeline files directly into . without hooks (aws#2911)

* feat: Support creating pipeline files directly into . without hooks

* Integration test for pipeline init and pipeline bootstrap (aws#2841)

* Expose Environment._get_stack_name for integ test to predict stack name

* Add integ test for pipeline bootstrap

* Add init integ test

* small UX improvements: (aws#2914)

* small UX improvements:
1. show a message when the user cancels a bootstrapping command.
2. Don't prompt for CI/CD provider or provider templates if there is only one choice.
3. Make PipelineFileAlreadyExistsError a UserError.
4. use the Colored class instead of fg='color' when prompting a colored message.
5. Fix a bug where we were not allowing empty response for not required questions.

* Fix Integration Test: We now don't ask the user to select a provider's pipeline template if there is only one

* Add docs for PipelineFileAlreadyExistsError

* make black happy

* Sam pipelines s3 security (aws#2975)

* Deny non https requests for the artifacts S3 bucket

* enable bucket serverside logging

* add integration tests for artifacts bucket SSL-only requests and access logging

* typo

* Ensure the ArtifactsLoggingBucket denies non ssl requests (aws#2976)

* Sam pipelines ux round 3 (aws#2979)

* rename customer facing message 'CI/CD provider' to 'CI/CD system'

* add a note about what 'Environment Name' is during the pipeline bootstrap guided context

* Apply suggestions from code review

typo

Co-authored-by: Chris Rehn <crehn@outlook.com>

Co-authored-by: Chris Rehn <crehn@outlook.com>

* let pipeline IAM user assume only IAM roles tagged with Role=pipeline-execution-role (aws#2982)

* Adding AWS_ prefix to displayed out. (aws#2993)

Co-authored-by: Tarun Mall <tarun@amazon.noreply.github.com>

* Add region to pipeline bootstrap interactive flow (aws#2997)

* Ask AWS region in bootstrap interactive flow

* Read default region from boto session first

* Fix a unit test

* Inform write to pipelineconfig.toml at the end of bootstrap (aws#3002)

* Print info about pipelineconfig.toml after resources are bootstrapped

* Update samcli/commands/pipeline/bootstrap/cli.py

Co-authored-by: Chris Rehn <crehn@outlook.com>

Co-authored-by: Chris Rehn <crehn@outlook.com>

* List detected env names in pipeline init when prompt to input the env name (aws#3000)

* Allow question.question can be resolved using key path

* Pass the list of env names message (environment_names_message) into pipeline init interactive flow context

* Update samcli/commands/pipeline/init/interactive_init_flow.py

Co-authored-by: Chris Rehn <crehn@outlook.com>

* Fix unit test (trigger pr builds)

* Fix integ test

* Fix integ test

Co-authored-by: Chris Rehn <crehn@outlook.com>

* Adding account id to bootstrap message. (aws#2998)

* Adding account id to bootstrap message.

* adding docstring

* Addressing PR comments.

* Adding unit tests.

* Fixing unit tests.

Co-authored-by: Tarun Mall <tarun@amazon.noreply.github.com>

* Cfn creds fix (aws#3014)

* Removing pipeline user creds from cfn output. This maintains same user exp.

Co-authored-by: Tarun Mall <tarun@amazon.noreply.github.com>

* Ux bootstrap revamp 20210706 (aws#3021)

* Add intro paragraph to bootstrap

* Add switch account prompt

* Revamp stage definition prompt

* Revamp existing resources prompt

* Revamp security prompt

* Allow answers to be changed later

* Add exit message for bootstrap

* Add exit message for bootstrap (1)

* Add indentation to review values

* Add "Below is the summary of the answers:"

* Sweep pylint errors

* Update unit tests

* Update samcli/commands/pipeline/bootstrap/guided_context.py

Co-authored-by: Chris Rehn <crehn@outlook.com>

* Update samcli/commands/pipeline/bootstrap/guided_context.py

Co-authored-by: Chris Rehn <crehn@outlook.com>

* Update samcli/commands/pipeline/bootstrap/guided_context.py

Co-authored-by: Chris Rehn <crehn@outlook.com>

* Update samcli/commands/pipeline/bootstrap/guided_context.py

Co-authored-by: Chris Rehn <crehn@outlook.com>

* Update samcli/commands/pipeline/bootstrap/guided_context.py

Co-authored-by: Chris Rehn <crehn@outlook.com>

* Update samcli/commands/pipeline/bootstrap/guided_context.py

Co-authored-by: Chris Rehn <crehn@outlook.com>

* Update samcli/commands/pipeline/bootstrap/guided_context.py

Co-authored-by: Chris Rehn <crehn@outlook.com>

* Update samcli/commands/pipeline/bootstrap/guided_context.py

Co-authored-by: Chris Rehn <crehn@outlook.com>

* Update samcli/commands/pipeline/bootstrap/cli.py

Co-authored-by: Chris Rehn <crehn@outlook.com>

* Update unit tests

* Add bold to other literals

Co-authored-by: Chris Rehn <crehn@outlook.com>

* Adding account condition for CFN execution role. (aws#3027)

Co-authored-by: Tarun Mall <tarun@amazon.noreply.github.com>

* pipeline UX revamp 20210707 (aws#3031)

* Allow running bootstrap inside pipeline init

* Select account credential source within bootstrap

* Add bootstrap decorations within pipeline init

* Removing ip range option from bootstrap. (aws#3036)

* Removing ip range option from bootstrap.

* Fixing unit test from UX PR.

Co-authored-by: Tarun Mall <tarun@amazon.noreply.github.com>

* Fix toml file incorrect read/write in init --bootstrap (aws#3037)

* Temporarily removing account fix. (aws#3038)

Co-authored-by: Tarun Mall <tarun@amazon.noreply.github.com>

* Rename environment to stage (aws#3040)

* Improve account source selection (aws#3042)

* Fixing various cosmetics UX issues with pipeline workflow. (aws#3046)

* Fixing credential to credentials

* Forcing text color to yellow.

* Adding new line after stage diagram.

* Adding extra line after checking bootstrap message.

* Renaming config -> configuration

* account source -> credential source

* Removing old message.

* Fixing indentation in list.

* Fixing bunch of indentation.

* fixing f string

Co-authored-by: Tarun Mall <tarun@amazon.noreply.github.com>

* Auto skip questions if stage detected (aws#3045)

* Autofill question if default value is presented

* Allow to use index to select stage names (aws#3051)

* Updating message when bootstrap stages are missing. (aws#3058)

* Updating message when bootstrap stages are missing.

* Fixing indendation

Co-authored-by: Tarun Mall <tarun@amazon.noreply.github.com>

* Fixing bootstrap integ tests. (aws#3061)

* Fixing bootstrap integ tests.

* Cleaning up some integ tests.

* Using environment variables when running integ test on CI.

* Using expression instead of full loop.

* Adding instruction to use default profile on local.

Co-authored-by: Tarun Mall <tarun@amazon.noreply.github.com>

* Fix bootstrap test region (#3064)

* Fix bootstrap region in integ test

* Fix regions in non-interactive mode as well

* Add more pipeline init integ test (aws#3065)

* Fix existing pipeline init integ test

* Add more pipeline init integ tests

* Config file bug (aws#3066)

* Validating config file after bootstrap stack creation.

* Validating config file after bootstrap.

Co-authored-by: Tarun Mall <tarun@amazon.noreply.github.com>

* Fix pipeline init integ test because of pipelineconfig file exists (aws#3067)

* Make stage name randomized to avoid race condition among multi canary runs (aws#3078)

* Load number of stages from pipeline template (aws#3059)

* Load number of stages from templates

* Rename variable and add debug log

* Add encoding to open()

* Allow roles with Tag aws-sam-pipeline-codebuild-service-role to assume PipelineExecutionRole (aws#2950)

* pipeline init UX: Ask to confirm when file exists (aws#3079)

* Ask to confirm overriding if files already exist, or save to another directory

* Add doc links (aws#3087)

* Adding accidentally removed tests back. (aws#3088)

Co-authored-by: Tarun Mall <tarun@amazon.noreply.github.com>

Co-authored-by: elbayaaa <72949274+elbayaaa@users.noreply.github.com>
Co-authored-by: Chris Rehn <crehn@outlook.com>
Co-authored-by: Ahmed Elbayaa <elbayaaa@amazon.com>
Co-authored-by: Tarun <c2tarun@users.noreply.github.com>
Co-authored-by: Tarun Mall <tarun@amazon.noreply.github.com>
@konstantin-constructor
Copy link

Is there anyway to edit the waiter config without touching python code? (Like using an environment var or something?)

I am interested in the same question. We really need this as an option as we have a valid use case where the cloudformation-deploy is going over 1h as it is waiting for the ASG to get all its members ready and only then starts waiting for its Warmpool members to get ready, too.

@stealthycoin
Copy link
Contributor

I agree there needs to be a better way of giving the cloudformation deploy command a ballpark estimate of how long it should be expected to take. This issue should be used for design ideas and discussions and tracking interest in this feature.

#6828 details our new contribution process.

@vvucetic
Copy link

Here you go #6905

@tim-finnigan tim-finnigan added feature-request A feature should be added or improved. cloudformation package-deploy labels May 2, 2022
@tim-finnigan tim-finnigan added customization Issues related to CLI customizations (located in /awscli/customizations) p3 This is a minor priority issue labels Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cloudformation package-deploy customization Issues related to CLI customizations (located in /awscli/customizations) feature-request A feature should be added or improved. p3 This is a minor priority issue
Projects
None yet
Development

No branches or pull requests

10 participants