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 instance-connect is not using --profile for the connection #1846

Open
czunker opened this issue Sep 22, 2023 · 4 comments
Open

aws instance-connect is not using --profile for the connection #1846

czunker opened this issue Sep 22, 2023 · 4 comments
Labels
bug Something isn't working v9.1

Comments

@czunker
Copy link
Contributor

czunker commented Sep 22, 2023

Describe the bug
When I run instance-connect with --profile I get this error:

cnquery run aws ec2 instance-connect ec2-user@i-08db02ceb047ea7fb --profile AdministratorAccess-1234567890 --region eu-central-1 -c 'asset{ name title ids platform }'
! CLI pre-processing encountered an issue error="unknown flag: --profile"
! using builtin provider for aws
→ loaded configuration from /etc/opt/mondoo/mondoo.yml using source default
→ no AWS region found, using us-east-1
FTL failed to run query error="operation error STS: GetCallerIdentity, exceeded maximum number of attempts, 3, failed to sign request: failed to retrieve credentials: failed to refresh cached credentials, no EC2 IMDS role found, operation error ec2imds: GetMetadata, exceeded maximum number of attempts, 3, request send failed, Get \"http://169.254.169.254/latest/meta-data/iam/security-credentials/\": dial tcp 169.254.169.254:80: i/o timeout"

Using the was CLI works:

aws ec2-instance-connect ssh --instance-id i-08db02ceb047ea7fb --region eu-central-1 --profile AdministratorAccess-1234567890                                              
The authenticity of host '3.71.8.75 (3.71.8.75)' can't be established.
ED25519 key fingerprint is SHA256:yBfOVxhFjUtRSH37CZ27x3TUWYKvNzsaK71mJF8AgBI.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '3.71.8.75' (ED25519) to the list of known hosts.
   ,     #_
   ~\_  ####_        Amazon Linux 2023
  ~~  \_#####\
  ~~     \###|
  ~~       \#/ ___   https://aws.amazon.com/linux/amazon-linux-2023
   ~~       V~' '->
    ~~~         /
      ~~._.   _/
         _/ _/
       _/m/'
[ec2-user@ip-172-31-21-20 ~]$ 

Setting the env var, it works independent of the --profile parameter:

export AWS_PROFILE=AdministratorAccess-1234567890
cnquery run aws ec2 instance-connect ec2-user@i-08db02ceb047ea7fb --region eu-central-1 -c 'asset{ name title ids platform }'                                            
! CLI pre-processing encountered an issue error="unknown flag: --region"
! using builtin provider for aws
→ loaded configuration from /etc/opt/mondoo/mondoo.yml using source default
→ no AWS region found, using us-east-1
! using builtin provider for os
asset: {
  title: "Amazon Linux 2023"
  platform: "amazonlinux"
  ids: [
    0: "//platformid.api.mondoo.app/hostname/ip-172-31-21-20.eu-central-1.compute.internal"
  ]
  name: "ip-172-31-21-20.eu-central-1.compute.internal"
}

To Reproduce
Steps to reproduce the behavior:

  1. Create new EC2 instance
  2. Set up an AWS profile
  3. Try instance-connect with this profile
  4. Note the error

Expected behavior
The parameter should set the profile.

@czunker czunker added bug Something isn't working v9 labels Sep 22, 2023
@czunker czunker added this to the v9 milestone Sep 22, 2023
@czunker
Copy link
Contributor Author

czunker commented Sep 22, 2023

This also happens with aws ssm

@czunker
Copy link
Contributor Author

czunker commented Sep 22, 2023

I just read the help text for this flag. I don't have the file ~/.aws/credentials on my system.

I created the profile using aws sso configure

@vjeffrey
Copy link
Contributor

ohh, it looks like those creds get put in ~/.aws/config...ill take a look at this, i would have expected the api to read it in both locations if it puts sso stuff in ~/.aws/config ...maybe there's an extra option we need to pass

@arlimus arlimus added v9.1 and removed v9 labels Sep 27, 2023
@arlimus
Copy link
Member

arlimus commented Sep 27, 2023

From the feedback I gather this is an issue in v8 as well. I assume it's not a release blocker and we want to get it fixed shortly after.

@arlimus arlimus closed this as completed Sep 27, 2023
@arlimus arlimus reopened this Sep 27, 2023
@arlimus arlimus removed this from the v9 milestone Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working v9.1
Projects
None yet
Development

No branches or pull requests

3 participants