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_PROFILE not working, commands failing #1941

Closed
bombillazo opened this issue May 6, 2022 · 5 comments
Closed

AWS_PROFILE not working, commands failing #1941

bombillazo opened this issue May 6, 2022 · 5 comments
Assignees
Labels
kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed
Milestone

Comments

@bombillazo
Copy link

bombillazo commented May 6, 2022

What happened?

In pulumi-aws v5+, if the provider profile is specified by the config, it is now required to set the AWS_ACCESS_KEY and AWS_SECRET_KEY for that specific profile. Previously if there were no credentials, Terraform would fall back on the credentials found in the environment.

GH Issue
Terraform Provider Update

Given this, I am attempting to pass AWS_PROFILE as an env parameter to the actions as recommended here. However, this does not work and there is no way to relate the credentials to the was profile so Pulumi does not fail the command.

Steps to reproduce

  1. Have an AWS profile set up in your aws provider.
- name: Pulumi preview
        uses: pulumi/actions@v3
        with:
          command: preview
          stack-name: myStack
        env:
          PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
          AWS_PROFILE: ${{ env.AWS_PROFILE }}
          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          AWS_REGION: ${{ env.AWS_REGION }}

Expected Behavior

Actions can use the credentials set in the CI/CD process to the profile passed in the actions automatically. Command runs successfully.

Actual Behavior

Commands fail with the following error:

error configuring Terraform AWS Provider: failed to get shared config profile, my-profile

Versions used

@pulumi/aws 5.4.0
@pulumi/awsx 0.40.0
@pulumi/pulumi 3.32.1
@pulumi/random 4.6.0

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

@bombillazo bombillazo added the kind/bug Some behavior is incorrect or out of spec label May 6, 2022
@mikhailshilkov mikhailshilkov transferred this issue from pulumi/actions May 8, 2022
@jkisk
Copy link
Contributor

jkisk commented May 12, 2022

Sorry for the confusion here, I believe you want to use a different action in a previous step, like: https://github.com/aws-actions/configure-aws-credentials, rather than passing aws creds via the env of the pulumi action.

@ringods
Copy link
Member

ringods commented Jun 8, 2022

@jkisk I think this is unrelated to Github Actions. On my laptop, I'm using export AWS_PROFILE=atriso to point to the correct sections in the following files:

~/.aws/config

[profile atriso]
region=eu-west-1
output=json

~/.aws/credentials

[atriso]
aws_access_key_id=<mykey>
aws_secret_access_key=<mysecret>

Only exporting AWS_PROFILE works when using the AWS CLI. For instance, aws iam list-users returns me the actual list of users I have in my AWS account.

With Pulumi, this worked when using pulumi-aws v3. This morning, I upgraded to pulumi-aws v5 and I get the error:

$ pulumi preview
Previewing update (production)

View Live: https://app.pulumi.com/<redacted>

     Type                 Name             Plan     Info
     pulumi:pulumi:Stack  root-production           
     └─ aws:iam:User      github-user               1 error
 
Diagnostics:
  aws:iam:User (github-user):
    error: unable to validate AWS AccessKeyID and/or SecretAccessKey - see https://pulumi.io/install/aws.html for details on configuration

This is clearly a regression. Probably in the upstream TF provider?

@danielrbradley
Copy link
Member

One recent change is that we've started pre-validating credentials up-front rather than waiting for a resource to fail to deploy. One workaround is to set skipCredentialsValidation: true which will skip this step. However, there's also an additional change which should be released in the next hour (v5.7.1) which should address some issues in this credentials validation process.

@ringods
Copy link
Member

ringods commented Jun 8, 2022

This seems to be a duplicate of #1995

@stack72 stack72 self-assigned this Jun 15, 2022
@stack72 stack72 added the resolution/fixed This issue was fixed label Jun 15, 2022
@stack72 stack72 added this to the 0.74 milestone Jun 15, 2022
@stack72
Copy link
Contributor

stack72 commented Jun 15, 2022

I believe this is fixed via #2004 and will go out into production with the new release this week

@stack72 stack72 closed this as completed Jun 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed
Projects
None yet
Development

No branches or pull requests

5 participants