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

clidriver in version 1.13.0 is broken #2999

Closed
karimtabet opened this issue Nov 29, 2017 · 21 comments
Closed

clidriver in version 1.13.0 is broken #2999

karimtabet opened this issue Nov 29, 2017 · 21 comments

Comments

@karimtabet
Copy link

karimtabet commented Nov 29, 2017

After pip installing awscli==1.13.0 in a Docker container based from python:3.6.2, running any aws commands returns

Traceback (most recent call last):
  File "/usr/local/bin/aws", line 19, in <module>
    import awscli.clidriver
  File "/usr/local/lib/python3.6/site-packages/awscli/clidriver.py", line 24, in <module>
    from botocore.history import get_global_history_recorder
ModuleNotFoundError: No module named 'botocore.history'

Reverted to awscli==1.12.0 and everything works fine.

@joguSD
Copy link
Contributor

joguSD commented Nov 29, 2017

Sounds like your cli and botocore version are out of sync some how. For awscli v1.13.0 make sure you have at least botocore v1.8.3.

@joguSD joguSD added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Nov 29, 2017
@cabral404
Copy link

cabral404 commented Dec 7, 2017

I'm having the exact same problem:

awscli==1.14.5
boto==2.48.0
boto3==1.4.8
botocore==1.8.9
Traceback (most recent call last):
  File "/usr/local/bin/aws", line 19, in <module>
    import awscli.clidriver
  File "/usr/local/lib/python2.7/dist-packages/awscli/clidriver.py", line 24, in <module>
    from botocore.history import get_global_history_recorder
ImportError: No module named history

As @karimtabet said, reverting to 1.12.0 works.

@mherger
Copy link

mherger commented Dec 13, 2017

Exact same error as @cabral404, using:

aws-cli/1.14.6
botocore/1.8.12
Python/2.7.12

@Danpiel
Copy link

Danpiel commented Dec 13, 2017

Got same problem when run with my user, if sudo is used aws cli runs fine, seems it has permission problems when installed from packages or pip.

My workaround looks like this:

  • Remove aws cli from pip with pip uninstall awscli
    or
  • Remove remove aws-cli packages (like packman -R aws-cli)
  • Then use aws bundle
curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
unzip awscli-bundle.zip
./awscli-bundle/install -b ~/bin/aws
export PATH=~/bin:$PATH

More info are here http://docs.aws.amazon.com/cli/latest/userguide/awscli-install-bundle.html#install-bundle-user

@joguSD
Copy link
Contributor

joguSD commented Dec 20, 2017

While reverting to an earlier version may work, newer versions not working due to imports failing sounds like an issue with how the awscli package was installed or how python packages in general are managed on your system. In this case there's probably another version of botocore somewhere that's taking precedence over the one being displayed in the output of pip freeze.

As @Danpiel mentions removing all other installation methods and using a bundled installer is a possible solution as that uses an isolated virtualenv to run the aws cli.

For anybody still running into this please provide the following:

  1. What operating system are you using?
  2. How did you install the awscli package?
  3. How did you attempt update the awscli package?

@mariosotil
Copy link

This fixed it for me:

$ sudo -H pip install awscli --upgrade

@sharmaansh21
Copy link

aws ec2 describe-regions --query 'Regions[].{Name:RegionName}' --output text --region us-east-1
Traceback (most recent call last):
  File "/usr/bin/aws", line 19, in <module>
    import awscli.clidriver
  File "/usr/lib/python2.7/dist-packages/awscli/clidriver.py", line 24, in <module>
    from botocore.history import get_global_history_recorder
ImportError: No module named history

I am also facing same issue.

@jfairchild
Copy link

same issue as @optimisticanshul
aws version: awscli-1.14.19
botocore: botocore-1.8.23
python: Python 2.7.13

@jfairchild
Copy link

Workaround:

  1. pip uninstall boto3 -y
  2. pip uninstall boto -y
  3. pip uninstall botocore -y
  4. pip install botocore --upgrade

Result aws works

@hapx101
Copy link

hapx101 commented Jan 17, 2018

I am facing similar issue. Only difference being that when I try and access it as root user, I am getting the error, but when accessing it as ec2-user, it works just fine.

Output as ec2-user

[ec2-user@ip-x-x-x-x ~]$ aws route53 change-resource-record-sets --hosted-zone-id $PrivateHostedZoneId --change-batch file:///home/ec2-user/change.json
{
    "ChangeInfo": {
        "Status": "PENDING",
        "Comment": "Create route53 DNS entry at instance boot up",
        "SubmittedAt": "2018-01-17T12:30:45.534Z",
        "Id": "/change/C1IG3ETCO6MGVW"
    }
}

Output as root user

[root@ip-x-x-x-x ec2-user]# aws route53 change-resource-record-sets --hosted-zone-id $PrivateHostedZoneId --change-batch file:///home/ec2-user/change.json
Traceback (most recent call last):
  File "/usr/bin/aws", line 19, in <module>
    import awscli.clidriver
  File "/usr/lib/python2.7/dist-packages/awscli/clidriver.py", line 24, in <module>
    from botocore.history import get_global_history_recorder
ImportError: No module named history

aws-cli: 1.14.9
Python: 2.7.12
Linux: 4.9.76-3.78.amzn1.x86_64
botocore: 1.8.13

@milgner
Copy link

milgner commented Feb 16, 2018

Also seeing the same problem.

Linux: Arch Linux
Python: 3.6.4
aws-cli 1.14.40-1
botocore: 1.8.44-1

Tried to upgrade botocore via pip, unsuccessfully so far.

Update: I also tried sudo pip install awscli --force-reinstall --upgrade which was mentioned in #641 but that didn't help either.

@authalic
Copy link

Same problem here using Windows:

platform: win32
python: 3.5.2
awscli: 1.14.41
botocore: 1.8.45

I have tried the suggested workarounds above, with the uninstall and reinstall of awscli and botocore, and I'm still getting the message:

  File "C:\python\Python3\Scripts\aws.cmd", line 50, in <module>
    import awscli.clidriver
ImportError: No module named awscli.clidriver

@JordonPhillips
Copy link
Member

If you have the CLI installed via any mechanism other than pip (such as a linux package manager) then you will need to uninstall there too to make sure to clean out your system before you reinstall. For Windows I highly recommend using the installer we provide here

@hflamboauto1
Copy link

hflamboauto1 commented Mar 6, 2018

same here but fixed with upgrades.
failed ones

boto (2.48.0)
boto3 (1.4.7)
botocore (1.7.1)
pip install --upgrade boto3
pip install --upgrade botocore
pip install --upgrade awscli
aws ecs list-container-instances --cluster my_ecs_cluster
{
    "containerInstanceArns": [

...
    ]
}

@rubelw
Copy link

rubelw commented Mar 12, 2018

Still getting error with most current versions:
awscli==1.14.53
boto==2.48.0
boto3==1.6.6
botocore==1.9.6

Command: aws ecr get-login --region $AWS_DEFAULT_REGION
Image: Ubuntu - aws/codebuild/docker:17.09.0

Traceback (most recent call last):
File "/usr/local/bin/aws", line 19, in
import awscli.clidriver
File "/usr/local/lib/python2.7/dist-packages/awscli/clidriver.py", line 24, in
from botocore.history import get_global_history_recorder
ImportError: No module named history

Found a working solution:
awscli==1.11.157
boto3==1.6.7
botocore==1.9.7

Looks like a fix was applied and boto3 and botocore versions were updated. Whatever updates they did, it seems to have fixed the problem.

@xtreamgit
Copy link

It looks like the was cannot parse the config file. I resolved the issue by creating a new ~/.aws/config file.

@mdeboer
Copy link

mdeboer commented May 23, 2018

I had the same issue on CentOS installing with yum. I removed the packages with yum and installed awscli with pip and now everything works fine.

@gfa
Copy link

gfa commented May 23, 2018

For those installing from centos 7 with epel, awscli was removed from epel and included in centos base repo. however the dependencies changed, just remove the following packages (if nothing else uses it)

python2-s3transfer python-colorama python2-botocore python2-rsa

then reinstall from centos-base repo

@kyleknap kyleknap removed the closing-soon This issue will automatically close in 4 days unless further comments are made. label Jun 14, 2018
@jamesls
Copy link
Member

jamesls commented Jun 20, 2018

Closing out old issue. As mentioned, the issue is due to older versions of botocore being used with the CLI. As long as you're installing via pip or any other supported installation methods, you will get a working version of the CLI.

@jamesls jamesls closed this as completed Jun 20, 2018
@rajesh6752
Copy link

rajesh6752 commented Jul 2, 2020

Remove the botocore packege
pip uninstall botocore

install awscli again
pip install awscli

Now its works for me

@AllanOricil
Copy link

AllanOricil commented Nov 21, 2020

sudo -H pip install awscli --upgrade

@mariosotil you saved us!

thoward-godaddy pushed a commit to thoward-godaddy/aws-cli that referenced this issue Feb 12, 2022
thoward-godaddy pushed a commit to thoward-godaddy/aws-cli that referenced this issue Feb 12, 2022
* feat: Delete methods for CF stacks and S3 files (aws#2981)

* Added methods for cf and s3 files and init UI

* Added unit tests for utils methods and s3_uploader

* Removed s3_bucket and s3_prefix click options

* Fixed lint errors and added few unit tests

* Make black happy

* Added LOG statements

* Added and updated changes based on CR

* Fixed the unit tests in artifact_exporter.py

* Update HELP_TEXT in delete/command.py

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

* Updated code based on Chris' comments

* Small changes and fixes based on the comments

* Removed region prompt

* Update SAM context values for profile and region in delete_context.py

* Added typing for get_cf_template_name method

* Added stack_name prompt if the stack_name is not present in samconfig file

* Replace [] with get() for stack-name in delete_context.py

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

* Delete template artifacts (aws#3022)

* Added methods for cf and s3 files and init UI

* Added unit tests for utils methods and s3_uploader

* Removed s3_bucket and s3_prefix click options

* chore: Increase awareness of same file warning during package (aws#2946)

* chore: increase awareness of same file warning during package

* fix formatting & grammar

Co-authored-by: Mathieu Grandis <73313235+mgrandis@users.noreply.github.com>

* fix: Allow the base64Encoded field in REST Api, skip validation of unknown fields and validate missing statusCode for Http Api (aws#2941)

* fix API Gateway emulator:
 - skip validating the non allowed fields for Http Api Gateway, as it always skip the unknown fields
 - add base64Encoded as an allowed field for Rest Api gateway
 - base64 decoding will be always done for Http API gateway if the lambda response isBase64Encoded is true regardless the content-type
 - validate if statusCode is missing in case of Http API, and payload version 1.0

* - accept "true", "True", "false", "False" as valid isBase64Encoded values.
- Validate on other isBase64Encoded Values
- add more integration && unit test cases

* fix lint && black issues

* use smaller image to test Base64 response

* Fixed lint errors and added few unit tests

* Make black happy

* Added methods for deleting template artifacts

* Wait method added for delete cf api

* Added LOG statements

* Added and updated changes based on CR

* Fixed the unit tests in artifact_exporter.py

* Update HELP_TEXT in delete/command.py

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

* Updated code based on Chris' comments

* Added condition for resources that have deletionpolicy specified

* Small changes and fixes based on the comments

* Removed region prompt

* Added unit tests for ecr delete method and typing for methods

* Reformatted delete_context and added option to skip user prompts

* Removed return type from artifact_exporter for delete method

* Added unit tests for artifact_exporter and delete_context

* Added more unit tests for delete_context and artifact_exporter

* Added more unit tests for delete_context and artifact_exporter

* Added docs and comments for artifact_exporter and ecr_uploader

* Added log statements in delete_context and some updates in unit tests

* Changed force to no-prompts  and updated ecr delete method error handling

* Created a separate function for parsing ecr url in ecr_uploader

* Reformatted Template class init to pass template_str and init template_dict

* Changed how s3 url is obtained for resource_zip edge-case: aws:glue:job

* Fixed edge case where resource artifact points to a path style url

* run Make black

* Made the parse s3 url funcs protected and defined a parent method and modified delete method for ResourceImageDict

* Changed parse_ecr_url function name to parse_image_url

Co-authored-by: Mehmet Nuri Deveci <5735811+mndeveci@users.noreply.github.com>
Co-authored-by: Mathieu Grandis <73313235+mgrandis@users.noreply.github.com>
Co-authored-by: Mohamed Elasmar <71043312+moelasmar@users.noreply.github.com>
Co-authored-by: Chris Rehn <crehn@outlook.com>

* Get s3 info cf template (aws#3050)

* Added methods for cf and s3 files and init UI

* Added unit tests for utils methods and s3_uploader

* Removed s3_bucket and s3_prefix click options

* chore: Increase awareness of same file warning during package (aws#2946)

* chore: increase awareness of same file warning during package

* fix formatting & grammar

Co-authored-by: Mathieu Grandis <73313235+mgrandis@users.noreply.github.com>

* fix: Allow the base64Encoded field in REST Api, skip validation of unknown fields and validate missing statusCode for Http Api (aws#2941)

* fix API Gateway emulator:
 - skip validating the non allowed fields for Http Api Gateway, as it always skip the unknown fields
 - add base64Encoded as an allowed field for Rest Api gateway
 - base64 decoding will be always done for Http API gateway if the lambda response isBase64Encoded is true regardless the content-type
 - validate if statusCode is missing in case of Http API, and payload version 1.0

* - accept "true", "True", "false", "False" as valid isBase64Encoded values.
- Validate on other isBase64Encoded Values
- add more integration && unit test cases

* fix lint && black issues

* use smaller image to test Base64 response

* Fixed lint errors and added few unit tests

* Make black happy

* Added methods for deleting template artifacts

* Wait method added for delete cf api

* Added LOG statements

* Added and updated changes based on CR

* Fixed the unit tests in artifact_exporter.py

* Update HELP_TEXT in delete/command.py

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

* Updated code based on Chris' comments

* Added condition for resources that have deletionpolicy specified

* Small changes and fixes based on the comments

* Removed region prompt

* Added unit tests for ecr delete method and typing for methods

* Reformatted delete_context and added option to skip user prompts

* Removed return type from artifact_exporter for delete method

* Added unit tests for artifact_exporter and delete_context

* Added more unit tests for delete_context and artifact_exporter

* Added more unit tests for delete_context and artifact_exporter

* Added docs and comments for artifact_exporter and ecr_uploader

* Added log statements in delete_context and some updates in unit tests

* Changed force to no-prompts  and updated ecr delete method error handling

* Created a separate function for parsing ecr url in ecr_uploader

* Reformatted Template class init to pass template_str and init template_dict

* Changed how s3 url is obtained for resource_zip edge-case: aws:glue:job

* Fixed edge case where resource artifact points to a path style url

* run Make black

* Made the parse s3 url funcs protected and defined a parent method and modified delete method for ResourceImageDict

* Added methods to extract s3 info from cf template

* Added testing for get_s3_info method for artifact_exporter and s3_uploader methods

* Removed commented code and updated method docstring

* Better error handling for s3 delete artifacts and fixed bug for getting s3 resources information

* Changed get_s3_info to get_property_value and changed output text for s3 delete method

Co-authored-by: Mehmet Nuri Deveci <5735811+mndeveci@users.noreply.github.com>
Co-authored-by: Mathieu Grandis <73313235+mgrandis@users.noreply.github.com>
Co-authored-by: Mohamed Elasmar <71043312+moelasmar@users.noreply.github.com>
Co-authored-by: Chris Rehn <crehn@outlook.com>

* Sam delete integration testing (aws#3076)

* Added methods for cf and s3 files and init UI

* Added unit tests for utils methods and s3_uploader

* Removed s3_bucket and s3_prefix click options

* chore: Increase awareness of same file warning during package (aws#2946)

* chore: increase awareness of same file warning during package

* fix formatting & grammar

Co-authored-by: Mathieu Grandis <73313235+mgrandis@users.noreply.github.com>

* fix: Allow the base64Encoded field in REST Api, skip validation of unknown fields and validate missing statusCode for Http Api (aws#2941)

* fix API Gateway emulator:
 - skip validating the non allowed fields for Http Api Gateway, as it always skip the unknown fields
 - add base64Encoded as an allowed field for Rest Api gateway
 - base64 decoding will be always done for Http API gateway if the lambda response isBase64Encoded is true regardless the content-type
 - validate if statusCode is missing in case of Http API, and payload version 1.0

* - accept "true", "True", "false", "False" as valid isBase64Encoded values.
- Validate on other isBase64Encoded Values
- add more integration && unit test cases

* fix lint && black issues

* use smaller image to test Base64 response

* Fixed lint errors and added few unit tests

* Make black happy

* Added methods for deleting template artifacts

* Wait method added for delete cf api

* Added LOG statements

* Added and updated changes based on CR

* Fixed the unit tests in artifact_exporter.py

* Update HELP_TEXT in delete/command.py

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

* Updated code based on Chris' comments

* Added condition for resources that have deletionpolicy specified

* Small changes and fixes based on the comments

* Removed region prompt

* Added unit tests for ecr delete method and typing for methods

* Reformatted delete_context and added option to skip user prompts

* Removed return type from artifact_exporter for delete method

* Added unit tests for artifact_exporter and delete_context

* Added more unit tests for delete_context and artifact_exporter

* Added more unit tests for delete_context and artifact_exporter

* Added docs and comments for artifact_exporter and ecr_uploader

* Added log statements in delete_context and some updates in unit tests

* Init integration tests methods for sam delete

* Added more template files as a list for sam delete integration testing

* Changed force to no-prompts  and updated ecr delete method error handling

* Created a separate function for parsing ecr url in ecr_uploader

* Reformatted Template class init to pass template_str and init template_dict

* Changed how s3 url is obtained for resource_zip edge-case: aws:glue:job

* Fixed edge case where resource artifact points to a path style url

* run Make black

* Added 2 more integrations tests no_stack_deployed and delete for image type resources

* Made the parse s3 url funcs protected and defined a parent method and modified delete method for ResourceImageDict

* Added methods to extract s3 info from cf template

* Added testing for get_s3_info method for artifact_exporter and s3_uploader methods

* Added few more integration tests for delete

* Merged delete-template-artifacts branch code and updated this branch code

* Added tests for no prefix present for zip and image

* Added a check to confirm input stack is deleted for all the integration tests

* Removed commented code and updated method docstring

* Better error handling for s3 delete artifacts and fixed bug for getting s3 resources information

* Changed get_s3_info to get_property_value and changed output text for s3 delete method

* Added integration test for deleting nested stacks

Co-authored-by: Mehmet Nuri Deveci <5735811+mndeveci@users.noreply.github.com>
Co-authored-by: Mathieu Grandis <73313235+mgrandis@users.noreply.github.com>
Co-authored-by: Mohamed Elasmar <71043312+moelasmar@users.noreply.github.com>
Co-authored-by: Chris Rehn <crehn@outlook.com>

* Auto ECR Companion Stack Deletion (aws#3080)

* Added ecr_bootstrap

* Added companion_stack_manager

* Added Companion Stack Manager

* Added update_companion_stack

* Updated companion_stack_builder File Name

* Formatted with Black

* Updated get_unreferenced_repos

* Updated guided_context to Use Companion Stack

* Added Delete Auto Create ECR Repo Prompt

* Updated prompt_image_repository Flow

* Added --resolve-image-repos

* Addressed Some of Pylint Issues

* Updated Helper Text

* Updated Comments

* Fixed Typing

* Removed Unused Imports

* Updated Unit Tests

* Updated UX and Fixed Windows ANSI

* Updated Unit Tests

* Fixed Import Order

* Added Ignore Import Check

* Added Integration Tests

* Updated help text.

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

* Added Comments for Name Generation

* Updated Image Option Validator

* Updated CompanionStackBuilder to Use Dict instead of String

* Fixed Argument Ordering

* Added Mapping Information to Help Text

* Updated delete_unreferenced_repos Doc String

* Updated sync_repos Doc String

* Added Justification for ECR Repo Physical ID

* Refactored to be Less Coupled

* Refactored for prompt_specify_repos

* Fixed Unit Test

* Moved WaiterConfig Out of Methods

* Updated Typing

* Updated Managed S3 Template to be Dict

* Fixed Typo

* Added Comments for _save_image_repositories

* Fixed Pylint Issue

* Added Missing Check for unreferenced_repo_uris

* Updated Variable Name

* Fixed Typo

* Updated Windows Check to Use platform.system()

* Updated update_companion_stack Logic

* Fixed Comment Typo

* Fixed Typos

* Fixed Test Name

* Added methods for cf and s3 files and init UI

* Added unit tests for utils methods and s3_uploader

* Removed s3_bucket and s3_prefix click options

* chore: Increase awareness of same file warning during package (aws#2946)

* chore: increase awareness of same file warning during package

* fix formatting & grammar

Co-authored-by: Mathieu Grandis <73313235+mgrandis@users.noreply.github.com>

* fix: Allow the base64Encoded field in REST Api, skip validation of unknown fields and validate missing statusCode for Http Api (aws#2941)

* fix API Gateway emulator:
 - skip validating the non allowed fields for Http Api Gateway, as it always skip the unknown fields
 - add base64Encoded as an allowed field for Rest Api gateway
 - base64 decoding will be always done for Http API gateway if the lambda response isBase64Encoded is true regardless the content-type
 - validate if statusCode is missing in case of Http API, and payload version 1.0

* - accept "true", "True", "false", "False" as valid isBase64Encoded values.
- Validate on other isBase64Encoded Values
- add more integration && unit test cases

* fix lint && black issues

* use smaller image to test Base64 response

* Fixed lint errors and added few unit tests

* Make black happy

* Added methods for deleting template artifacts

* Wait method added for delete cf api

* fix: pass copy of environment variables for keeping cache valid (aws#2943)

* fix: pass copy of environment variables for keeping cache valid

* add integ tests

* update docs

* make black happy

Co-authored-by: Qingchuan Ma <69653965+qingchm@users.noreply.github.com>

* Added LOG statements

* Added and updated changes based on CR

* Fixed the unit tests in artifact_exporter.py

* Update HELP_TEXT in delete/command.py

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

* fix: Skip build of Docker image if ImageUri is a valid ECR URL (aws#2934) (aws#2935)

* Updated code based on Chris' comments

* Added condition for resources that have deletionpolicy specified

* Small changes and fixes based on the comments

* Add condition to managed bucket policy (aws#2999)

* Removed region prompt

* Update appveyor.yml to do docker login on both dockerhub and Public ECR (aws#3005) (aws#3006)

Co-authored-by: Wing Fung Lau <4760060+hawflau@users.noreply.github.com>

* chore: bump version to 1.25.0 (aws#3007)

Co-authored-by: Sriram Madapusi Vasudevan <3770774+sriram-mv@users.noreply.github.com>

* temp: reduce python testing matrix (aws#3008)

* temp: disable testing against python 3.8, and enabled 3.7 (aws#3009)

* temp: disable testing against python 3.8, and enabled 3.7

* temp: disable testing against python 3.8, and enabled 3.7 & 3.6

* fix: enable all runtimes in python testing matrix (aws#3011)

* revert: enable all runtimes in python testing matrix

* fix indentation for yml

* Added unit tests for ecr delete method and typing for methods

* Reformatted delete_context and added option to skip user prompts

* Removed return type from artifact_exporter for delete method

* Added unit tests for artifact_exporter and delete_context

* Added more unit tests for delete_context and artifact_exporter

* chore: update to aws-sam-translator 1.37.0 (aws#3019)

* chore: bump version to 1.26.0 (aws#3020)

* Added more unit tests for delete_context and artifact_exporter

* Added docs and comments for artifact_exporter and ecr_uploader

* Added log statements in delete_context and some updates in unit tests

* Changed force to no-prompts  and updated ecr delete method error handling

* chore: Improved --resolve-s3 option documentation and deployment without s3 error messages (aws#2983)

* Improve documentation on --resolve-s3 option and improve s3 failure messages

* Changed indentation for integration test on s3 error message

* Fixed a typo in description

* Improve spacing on help text for resolve-s3 option

* Created a separate function for parsing ecr url in ecr_uploader

* Reformatted Template class init to pass template_str and init template_dict

* Changed how s3 url is obtained for resource_zip edge-case: aws:glue:job

* Fixed edge case where resource artifact points to a path style url

* run Make black

* Made the parse s3 url funcs protected and defined a parent method and modified delete method for ResourceImageDict

* Changed parse_ecr_url function name to parse_image_url

* Defined UI for auto ecr deleton and method calls from companion_stack_manager

* Added code for deleting repos from companion stack

* Handle json templates deployed to cf

* Changed the order of companion stack and ecr repos deletion

* Handle delete_failed status for ecr companion stack and changed delete_stack to include retain_resources

* Reformatted auto ecr deletion to handle deleting companion stack as input stack name

* Fixed and added more unit tests for delete_context

* When region is not provided, prompt user to enter profile and region

* Removed region prompt and reading it from current session or assign a default instead

* Added ECR resource in packageable_resources and refactored ecr companion stack deletion

* Added log statements and unit tests for ECRResource

* Better error handling for ecr delete_artifact

* Revert "Merge remote-tracking branch 'wiltons-repo/feat/auto-ecr' into auto-ecr-delete"

This reverts commit 0e159c2fa3630b874f13f19336802f6085a92de9, reversing
changes made to 1675b7ed231b6472d38eeeeb25e39f6310bbb86f.

* Added unit test for delete ecr repository

* Fixed small string nits and added docstring for ECRResource

* Added some unit tests for s3_uploader, ecr_uploader and delete_context

* Updated to context refresh only when region and profile have non None values and removed unused class variable in delete_context

* Added unit test for ResourceImageDict class methods

Co-authored-by: Wilton Wang <CoshUS@users.noreply.github.com>
Co-authored-by: Chris Rehn <crehn@outlook.com>
Co-authored-by: Mathieu Grandis <73313235+mgrandis@users.noreply.github.com>
Co-authored-by: Mehmet Nuri Deveci <5735811+mndeveci@users.noreply.github.com>
Co-authored-by: Mohamed Elasmar <71043312+moelasmar@users.noreply.github.com>
Co-authored-by: Qingchuan Ma <69653965+qingchm@users.noreply.github.com>
Co-authored-by: Alexis Facques <mail@alexisfacques.com>
Co-authored-by: Wing Fung Lau <4760060+hawflau@users.noreply.github.com>
Co-authored-by: Sriram Madapusi Vasudevan <3770774+sriram-mv@users.noreply.github.com>

* Sam delete bug fixes (aws#3122)

* Fixed small bugs for no_prompts and for deleting artifacts

* Updated integration tests and added test for termination protection for sam delete

* Added few more integration tests for guided and non-guided delete

* Updated handling termination protection and changed the order of deleting artifacts and stack

* Added comments for delete artifacts to handle intrinsic ref functions and handled this for image resources

* Added integration test for retaining s3 artifact

* Changed option_name to the correct values in delete_context

* Small UX fix and updated delete_prefix_artifacts method prefix to fetch S3 files

* Added a note in s3_uploader.py about using the api list_objects_v2

* add sam delete to pyinstaller hooks file

* fix typo

* resolve pr comments

Co-authored-by: hnnasit <84355507+hnnasit@users.noreply.github.com>
Co-authored-by: Chris Rehn <crehn@outlook.com>
Co-authored-by: Mehmet Nuri Deveci <5735811+mndeveci@users.noreply.github.com>
Co-authored-by: Mathieu Grandis <73313235+mgrandis@users.noreply.github.com>
Co-authored-by: Wilton Wang <CoshUS@users.noreply.github.com>
Co-authored-by: Qingchuan Ma <69653965+qingchm@users.noreply.github.com>
Co-authored-by: Alexis Facques <mail@alexisfacques.com>
Co-authored-by: Wing Fung Lau <4760060+hawflau@users.noreply.github.com>
Co-authored-by: Sriram Madapusi Vasudevan <3770774+sriram-mv@users.noreply.github.com>
thoward-godaddy pushed a commit to thoward-godaddy/aws-cli that referenced this issue Feb 12, 2022
* feat: Delete methods for CF stacks and S3 files (aws#2981)

* Added methods for cf and s3 files and init UI

* Added unit tests for utils methods and s3_uploader

* Removed s3_bucket and s3_prefix click options

* Fixed lint errors and added few unit tests

* Make black happy

* Added LOG statements

* Added and updated changes based on CR

* Fixed the unit tests in artifact_exporter.py

* Update HELP_TEXT in delete/command.py

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

* Updated code based on Chris' comments

* Small changes and fixes based on the comments

* Removed region prompt

* Update SAM context values for profile and region in delete_context.py

* Added typing for get_cf_template_name method

* Added stack_name prompt if the stack_name is not present in samconfig file

* Replace [] with get() for stack-name in delete_context.py

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

* Delete template artifacts (aws#3022)

* Added methods for cf and s3 files and init UI

* Added unit tests for utils methods and s3_uploader

* Removed s3_bucket and s3_prefix click options

* chore: Increase awareness of same file warning during package (aws#2946)

* chore: increase awareness of same file warning during package

* fix formatting & grammar

Co-authored-by: Mathieu Grandis <73313235+mgrandis@users.noreply.github.com>

* fix: Allow the base64Encoded field in REST Api, skip validation of unknown fields and validate missing statusCode for Http Api (aws#2941)

* fix API Gateway emulator:
 - skip validating the non allowed fields for Http Api Gateway, as it always skip the unknown fields
 - add base64Encoded as an allowed field for Rest Api gateway
 - base64 decoding will be always done for Http API gateway if the lambda response isBase64Encoded is true regardless the content-type
 - validate if statusCode is missing in case of Http API, and payload version 1.0

* - accept "true", "True", "false", "False" as valid isBase64Encoded values.
- Validate on other isBase64Encoded Values
- add more integration && unit test cases

* fix lint && black issues

* use smaller image to test Base64 response

* Fixed lint errors and added few unit tests

* Make black happy

* Added methods for deleting template artifacts

* Wait method added for delete cf api

* Added LOG statements

* Added and updated changes based on CR

* Fixed the unit tests in artifact_exporter.py

* Update HELP_TEXT in delete/command.py

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

* Updated code based on Chris' comments

* Added condition for resources that have deletionpolicy specified

* Small changes and fixes based on the comments

* Removed region prompt

* Added unit tests for ecr delete method and typing for methods

* Reformatted delete_context and added option to skip user prompts

* Removed return type from artifact_exporter for delete method

* Added unit tests for artifact_exporter and delete_context

* Added more unit tests for delete_context and artifact_exporter

* Added more unit tests for delete_context and artifact_exporter

* Added docs and comments for artifact_exporter and ecr_uploader

* Added log statements in delete_context and some updates in unit tests

* Changed force to no-prompts  and updated ecr delete method error handling

* Created a separate function for parsing ecr url in ecr_uploader

* Reformatted Template class init to pass template_str and init template_dict

* Changed how s3 url is obtained for resource_zip edge-case: aws:glue:job

* Fixed edge case where resource artifact points to a path style url

* run Make black

* Made the parse s3 url funcs protected and defined a parent method and modified delete method for ResourceImageDict

* Changed parse_ecr_url function name to parse_image_url

Co-authored-by: Mehmet Nuri Deveci <5735811+mndeveci@users.noreply.github.com>
Co-authored-by: Mathieu Grandis <73313235+mgrandis@users.noreply.github.com>
Co-authored-by: Mohamed Elasmar <71043312+moelasmar@users.noreply.github.com>
Co-authored-by: Chris Rehn <crehn@outlook.com>

* Get s3 info cf template (aws#3050)

* Added methods for cf and s3 files and init UI

* Added unit tests for utils methods and s3_uploader

* Removed s3_bucket and s3_prefix click options

* chore: Increase awareness of same file warning during package (aws#2946)

* chore: increase awareness of same file warning during package

* fix formatting & grammar

Co-authored-by: Mathieu Grandis <73313235+mgrandis@users.noreply.github.com>

* fix: Allow the base64Encoded field in REST Api, skip validation of unknown fields and validate missing statusCode for Http Api (aws#2941)

* fix API Gateway emulator:
 - skip validating the non allowed fields for Http Api Gateway, as it always skip the unknown fields
 - add base64Encoded as an allowed field for Rest Api gateway
 - base64 decoding will be always done for Http API gateway if the lambda response isBase64Encoded is true regardless the content-type
 - validate if statusCode is missing in case of Http API, and payload version 1.0

* - accept "true", "True", "false", "False" as valid isBase64Encoded values.
- Validate on other isBase64Encoded Values
- add more integration && unit test cases

* fix lint && black issues

* use smaller image to test Base64 response

* Fixed lint errors and added few unit tests

* Make black happy

* Added methods for deleting template artifacts

* Wait method added for delete cf api

* Added LOG statements

* Added and updated changes based on CR

* Fixed the unit tests in artifact_exporter.py

* Update HELP_TEXT in delete/command.py

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

* Updated code based on Chris' comments

* Added condition for resources that have deletionpolicy specified

* Small changes and fixes based on the comments

* Removed region prompt

* Added unit tests for ecr delete method and typing for methods

* Reformatted delete_context and added option to skip user prompts

* Removed return type from artifact_exporter for delete method

* Added unit tests for artifact_exporter and delete_context

* Added more unit tests for delete_context and artifact_exporter

* Added more unit tests for delete_context and artifact_exporter

* Added docs and comments for artifact_exporter and ecr_uploader

* Added log statements in delete_context and some updates in unit tests

* Changed force to no-prompts  and updated ecr delete method error handling

* Created a separate function for parsing ecr url in ecr_uploader

* Reformatted Template class init to pass template_str and init template_dict

* Changed how s3 url is obtained for resource_zip edge-case: aws:glue:job

* Fixed edge case where resource artifact points to a path style url

* run Make black

* Made the parse s3 url funcs protected and defined a parent method and modified delete method for ResourceImageDict

* Added methods to extract s3 info from cf template

* Added testing for get_s3_info method for artifact_exporter and s3_uploader methods

* Removed commented code and updated method docstring

* Better error handling for s3 delete artifacts and fixed bug for getting s3 resources information

* Changed get_s3_info to get_property_value and changed output text for s3 delete method

Co-authored-by: Mehmet Nuri Deveci <5735811+mndeveci@users.noreply.github.com>
Co-authored-by: Mathieu Grandis <73313235+mgrandis@users.noreply.github.com>
Co-authored-by: Mohamed Elasmar <71043312+moelasmar@users.noreply.github.com>
Co-authored-by: Chris Rehn <crehn@outlook.com>

* Sam delete integration testing (aws#3076)

* Added methods for cf and s3 files and init UI

* Added unit tests for utils methods and s3_uploader

* Removed s3_bucket and s3_prefix click options

* chore: Increase awareness of same file warning during package (aws#2946)

* chore: increase awareness of same file warning during package

* fix formatting & grammar

Co-authored-by: Mathieu Grandis <73313235+mgrandis@users.noreply.github.com>

* fix: Allow the base64Encoded field in REST Api, skip validation of unknown fields and validate missing statusCode for Http Api (aws#2941)

* fix API Gateway emulator:
 - skip validating the non allowed fields for Http Api Gateway, as it always skip the unknown fields
 - add base64Encoded as an allowed field for Rest Api gateway
 - base64 decoding will be always done for Http API gateway if the lambda response isBase64Encoded is true regardless the content-type
 - validate if statusCode is missing in case of Http API, and payload version 1.0

* - accept "true", "True", "false", "False" as valid isBase64Encoded values.
- Validate on other isBase64Encoded Values
- add more integration && unit test cases

* fix lint && black issues

* use smaller image to test Base64 response

* Fixed lint errors and added few unit tests

* Make black happy

* Added methods for deleting template artifacts

* Wait method added for delete cf api

* Added LOG statements

* Added and updated changes based on CR

* Fixed the unit tests in artifact_exporter.py

* Update HELP_TEXT in delete/command.py

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

* Updated code based on Chris' comments

* Added condition for resources that have deletionpolicy specified

* Small changes and fixes based on the comments

* Removed region prompt

* Added unit tests for ecr delete method and typing for methods

* Reformatted delete_context and added option to skip user prompts

* Removed return type from artifact_exporter for delete method

* Added unit tests for artifact_exporter and delete_context

* Added more unit tests for delete_context and artifact_exporter

* Added more unit tests for delete_context and artifact_exporter

* Added docs and comments for artifact_exporter and ecr_uploader

* Added log statements in delete_context and some updates in unit tests

* Init integration tests methods for sam delete

* Added more template files as a list for sam delete integration testing

* Changed force to no-prompts  and updated ecr delete method error handling

* Created a separate function for parsing ecr url in ecr_uploader

* Reformatted Template class init to pass template_str and init template_dict

* Changed how s3 url is obtained for resource_zip edge-case: aws:glue:job

* Fixed edge case where resource artifact points to a path style url

* run Make black

* Added 2 more integrations tests no_stack_deployed and delete for image type resources

* Made the parse s3 url funcs protected and defined a parent method and modified delete method for ResourceImageDict

* Added methods to extract s3 info from cf template

* Added testing for get_s3_info method for artifact_exporter and s3_uploader methods

* Added few more integration tests for delete

* Merged delete-template-artifacts branch code and updated this branch code

* Added tests for no prefix present for zip and image

* Added a check to confirm input stack is deleted for all the integration tests

* Removed commented code and updated method docstring

* Better error handling for s3 delete artifacts and fixed bug for getting s3 resources information

* Changed get_s3_info to get_property_value and changed output text for s3 delete method

* Added integration test for deleting nested stacks

Co-authored-by: Mehmet Nuri Deveci <5735811+mndeveci@users.noreply.github.com>
Co-authored-by: Mathieu Grandis <73313235+mgrandis@users.noreply.github.com>
Co-authored-by: Mohamed Elasmar <71043312+moelasmar@users.noreply.github.com>
Co-authored-by: Chris Rehn <crehn@outlook.com>

* Auto ECR Companion Stack Deletion (aws#3080)

* Added ecr_bootstrap

* Added companion_stack_manager

* Added Companion Stack Manager

* Added update_companion_stack

* Updated companion_stack_builder File Name

* Formatted with Black

* Updated get_unreferenced_repos

* Updated guided_context to Use Companion Stack

* Added Delete Auto Create ECR Repo Prompt

* Updated prompt_image_repository Flow

* Added --resolve-image-repos

* Addressed Some of Pylint Issues

* Updated Helper Text

* Updated Comments

* Fixed Typing

* Removed Unused Imports

* Updated Unit Tests

* Updated UX and Fixed Windows ANSI

* Updated Unit Tests

* Fixed Import Order

* Added Ignore Import Check

* Added Integration Tests

* Updated help text.

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

* Added Comments for Name Generation

* Updated Image Option Validator

* Updated CompanionStackBuilder to Use Dict instead of String

* Fixed Argument Ordering

* Added Mapping Information to Help Text

* Updated delete_unreferenced_repos Doc String

* Updated sync_repos Doc String

* Added Justification for ECR Repo Physical ID

* Refactored to be Less Coupled

* Refactored for prompt_specify_repos

* Fixed Unit Test

* Moved WaiterConfig Out of Methods

* Updated Typing

* Updated Managed S3 Template to be Dict

* Fixed Typo

* Added Comments for _save_image_repositories

* Fixed Pylint Issue

* Added Missing Check for unreferenced_repo_uris

* Updated Variable Name

* Fixed Typo

* Updated Windows Check to Use platform.system()

* Updated update_companion_stack Logic

* Fixed Comment Typo

* Fixed Typos

* Fixed Test Name

* Added methods for cf and s3 files and init UI

* Added unit tests for utils methods and s3_uploader

* Removed s3_bucket and s3_prefix click options

* chore: Increase awareness of same file warning during package (aws#2946)

* chore: increase awareness of same file warning during package

* fix formatting & grammar

Co-authored-by: Mathieu Grandis <73313235+mgrandis@users.noreply.github.com>

* fix: Allow the base64Encoded field in REST Api, skip validation of unknown fields and validate missing statusCode for Http Api (aws#2941)

* fix API Gateway emulator:
 - skip validating the non allowed fields for Http Api Gateway, as it always skip the unknown fields
 - add base64Encoded as an allowed field for Rest Api gateway
 - base64 decoding will be always done for Http API gateway if the lambda response isBase64Encoded is true regardless the content-type
 - validate if statusCode is missing in case of Http API, and payload version 1.0

* - accept "true", "True", "false", "False" as valid isBase64Encoded values.
- Validate on other isBase64Encoded Values
- add more integration && unit test cases

* fix lint && black issues

* use smaller image to test Base64 response

* Fixed lint errors and added few unit tests

* Make black happy

* Added methods for deleting template artifacts

* Wait method added for delete cf api

* fix: pass copy of environment variables for keeping cache valid (aws#2943)

* fix: pass copy of environment variables for keeping cache valid

* add integ tests

* update docs

* make black happy

Co-authored-by: Qingchuan Ma <69653965+qingchm@users.noreply.github.com>

* Added LOG statements

* Added and updated changes based on CR

* Fixed the unit tests in artifact_exporter.py

* Update HELP_TEXT in delete/command.py

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

* fix: Skip build of Docker image if ImageUri is a valid ECR URL (aws#2934) (aws#2935)

* Updated code based on Chris' comments

* Added condition for resources that have deletionpolicy specified

* Small changes and fixes based on the comments

* Add condition to managed bucket policy (aws#2999)

* Removed region prompt

* Update appveyor.yml to do docker login on both dockerhub and Public ECR (aws#3005) (aws#3006)

Co-authored-by: Wing Fung Lau <4760060+hawflau@users.noreply.github.com>

* chore: bump version to 1.25.0 (aws#3007)

Co-authored-by: Sriram Madapusi Vasudevan <3770774+sriram-mv@users.noreply.github.com>

* temp: reduce python testing matrix (aws#3008)

* temp: disable testing against python 3.8, and enabled 3.7 (aws#3009)

* temp: disable testing against python 3.8, and enabled 3.7

* temp: disable testing against python 3.8, and enabled 3.7 & 3.6

* fix: enable all runtimes in python testing matrix (aws#3011)

* revert: enable all runtimes in python testing matrix

* fix indentation for yml

* Added unit tests for ecr delete method and typing for methods

* Reformatted delete_context and added option to skip user prompts

* Removed return type from artifact_exporter for delete method

* Added unit tests for artifact_exporter and delete_context

* Added more unit tests for delete_context and artifact_exporter

* chore: update to aws-sam-translator 1.37.0 (aws#3019)

* chore: bump version to 1.26.0 (aws#3020)

* Added more unit tests for delete_context and artifact_exporter

* Added docs and comments for artifact_exporter and ecr_uploader

* Added log statements in delete_context and some updates in unit tests

* Changed force to no-prompts  and updated ecr delete method error handling

* chore: Improved --resolve-s3 option documentation and deployment without s3 error messages (aws#2983)

* Improve documentation on --resolve-s3 option and improve s3 failure messages

* Changed indentation for integration test on s3 error message

* Fixed a typo in description

* Improve spacing on help text for resolve-s3 option

* Created a separate function for parsing ecr url in ecr_uploader

* Reformatted Template class init to pass template_str and init template_dict

* Changed how s3 url is obtained for resource_zip edge-case: aws:glue:job

* Fixed edge case where resource artifact points to a path style url

* run Make black

* Made the parse s3 url funcs protected and defined a parent method and modified delete method for ResourceImageDict

* Changed parse_ecr_url function name to parse_image_url

* Defined UI for auto ecr deleton and method calls from companion_stack_manager

* Added code for deleting repos from companion stack

* Handle json templates deployed to cf

* Changed the order of companion stack and ecr repos deletion

* Handle delete_failed status for ecr companion stack and changed delete_stack to include retain_resources

* Reformatted auto ecr deletion to handle deleting companion stack as input stack name

* Fixed and added more unit tests for delete_context

* When region is not provided, prompt user to enter profile and region

* Removed region prompt and reading it from current session or assign a default instead

* Added ECR resource in packageable_resources and refactored ecr companion stack deletion

* Added log statements and unit tests for ECRResource

* Better error handling for ecr delete_artifact

* Revert "Merge remote-tracking branch 'wiltons-repo/feat/auto-ecr' into auto-ecr-delete"

This reverts commit 0e159c2fa3630b874f13f19336802f6085a92de9, reversing
changes made to 1675b7ed231b6472d38eeeeb25e39f6310bbb86f.

* Added unit test for delete ecr repository

* Fixed small string nits and added docstring for ECRResource

* Added some unit tests for s3_uploader, ecr_uploader and delete_context

* Updated to context refresh only when region and profile have non None values and removed unused class variable in delete_context

* Added unit test for ResourceImageDict class methods

Co-authored-by: Wilton Wang <CoshUS@users.noreply.github.com>
Co-authored-by: Chris Rehn <crehn@outlook.com>
Co-authored-by: Mathieu Grandis <73313235+mgrandis@users.noreply.github.com>
Co-authored-by: Mehmet Nuri Deveci <5735811+mndeveci@users.noreply.github.com>
Co-authored-by: Mohamed Elasmar <71043312+moelasmar@users.noreply.github.com>
Co-authored-by: Qingchuan Ma <69653965+qingchm@users.noreply.github.com>
Co-authored-by: Alexis Facques <mail@alexisfacques.com>
Co-authored-by: Wing Fung Lau <4760060+hawflau@users.noreply.github.com>
Co-authored-by: Sriram Madapusi Vasudevan <3770774+sriram-mv@users.noreply.github.com>

* Sam delete bug fixes (aws#3122)

* Fixed small bugs for no_prompts and for deleting artifacts

* Updated integration tests and added test for termination protection for sam delete

* Added few more integration tests for guided and non-guided delete

* Updated handling termination protection and changed the order of deleting artifacts and stack

* Added comments for delete artifacts to handle intrinsic ref functions and handled this for image resources

* Added integration test for retaining s3 artifact

* Changed option_name to the correct values in delete_context

* Small UX fix and updated delete_prefix_artifacts method prefix to fetch S3 files

* Added a note in s3_uploader.py about using the api list_objects_v2

* add sam delete to pyinstaller hooks file

* fix typo

* resolve pr comments

* fix refactoring issue, and add unit testing

Co-authored-by: hnnasit <84355507+hnnasit@users.noreply.github.com>
Co-authored-by: Chris Rehn <crehn@outlook.com>
Co-authored-by: Mehmet Nuri Deveci <5735811+mndeveci@users.noreply.github.com>
Co-authored-by: Mathieu Grandis <73313235+mgrandis@users.noreply.github.com>
Co-authored-by: Wilton Wang <CoshUS@users.noreply.github.com>
Co-authored-by: Qingchuan Ma <69653965+qingchm@users.noreply.github.com>
Co-authored-by: Alexis Facques <mail@alexisfacques.com>
Co-authored-by: Wing Fung Lau <4760060+hawflau@users.noreply.github.com>
Co-authored-by: Sriram Madapusi Vasudevan <3770774+sriram-mv@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests