aws-cloudformation / cloudformation-cli

The CloudFormation Provider Development Toolkit allows you to author your own resource providers and modules that can be used by CloudFormation.
Apache License 2.0
316 stars 158 forks source link

cfn init for hooks shows warning/error about AWS credentials - should clarify #959

Open mmaeng opened 1 year ago

mmaeng commented 1 year ago

cfn init

should be stand alone and able to be done offline. It has no need to access AWS accounts but currently not having your environment set up will cause an exception for all languages.

benbridts commented 1 year ago

Isn't this already the case (for init)?

on my machine:

~$ cfn --version
cfn 0.2.28

~$ aws sts get-caller-identity
Unable to locate credentials. You can configure credentials by running "aws configure".

~$ cfn init
Initializing new project
Do you want to develop a new resource(r) or a module(m) or a hook(h)?.
>> m
What's the name of your module type?
(<Organization>::<Service>::<Name>::MODULE)
>> Example::Service::Name::MODULE
Directory  /Users/ben/tmp/fragments  Created
Initialized a new project in /Users/ben/tmp

~$ ls
fragments/ rpdk.log
mmaeng commented 1 year ago

Thanks Ben!

For modules and resources that looks to be the case but for hooks it errors, and then proceeds to create the example anyway :P

$ cfn init -a hook -t test::test::test python38 --use-docker
Initializing new project
No region specified. Please ensure your AWS CLI is configured correctly: https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html

$ ls
README.md           hook-role.yaml      requirements.txt    rpdk.log            src                 template.yml        test-test-test.json

$ cfn init --region us-east-1 -a hook -t test::test::test python38 --use-docker
Initializing new project
No credentials specified. Please ensure your AWS CLI is configured correctly: https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html

$ ls
README.md           hook-role.yaml      requirements.txt    rpdk.log            src                 template.yml        test-test-test.json

Issue should be to clarify the error/warning during init for hooks