Score:0

How to remove a profile in aws-vault

th flag

I have used aws-vault add production to create a temporary credentials. Because there is no production named profile in .aws/credentials I decided to remove the credentials and configure a new one, with corrected name. For that I used aws-vault remove production. That of course only deleted the credentials, but not the profile name shown in the aws-vault list command output. Is there a way to delete that profile name?

Thanks in advance.

Score:1
pt flag

The profiles you see in aws-vault list correspond to profiles defined in your ~/.aws/config file. To remove a profile, edit ~/.aws/config and remove it. E.g., if I see:

$ aws-vault list
Profile                     Credentials                 Sessions                         
=======                     ===========                 ========                         
production                  production                  -                                
testing                     -                           -                               

Then in ~/.aws/config I will find:

[profile production]

[profile testing]

And if I remove the entry for [profile testing], I no longer see it in the output of aws-vault list:

$ aws-vault list
Profile                     Credentials                 Sessions                         
=======                     ===========                 ========                         
production                  production                  -                                

Here's a complete walkthrough to make sure we're both seeing the same behavior.

  1. I start with an empty credentials list:

    $ aws-vault list
    Profile                  Credentials              Sessions
    =======                  ===========              ========
    
  2. I add production credentials:

    $ aws-vault add production
    Enter Access Key ID: example
    Enter Secret Access Key:
    Added credentials to profile "production" in vault
    

    Which now appear in the list:

    $ aws-vault list
    Profile                  Credentials              Sessions
    =======                  ===========              ========
    production               production               -
    

    This creates a profile entry in ~/.aws/config:

    $ cat ~/.aws/config
    [profile production]
    
  3. If I remove those credentials:

    $ aws-vault remove production
    Delete credentials for profile "production"? (y|N) y
    Deleted credentials.
    

    The profile still shows up in the list even though the credentials have been deleted:

    $ aws-vault list
    Profile                  Credentials              Sessions
    =======                  ===========              ========
    production               -                        -
    
  4. If I remove the [profile production] entry from ~/.aws/config:

    $ sed -i '/profile production/d' ~/.aws/config
    

    Then the profile no longer appears in the output of aws-vault list:

    $ aws-vault list
    Profile                  Credentials              Sessions
    =======                  ===========              ========
    
urlator avatar
th flag
larsks, thanks. the problem is when I added production credentials to aws-vault (the same one that corresponds to name.production profile from ~/.aws/config) it didn't create a new profile inside ~/.aws/config, so there is nothing to be deleted there. try aws-vault add something (this something should not exist in the ~/.aws/config) and see what happens.
pt flag
I've updated my answer with a complete example of the behavior I'm seeing while trying this out locally. When I'm using `aws-vault`, (a) adding credentials creates a profile in `~/.aws/config` if it doesn't already exist, and (b) removing that profile entry prevents it from showing up in the output of `aws-vault list`.
urlator avatar
th flag
Hi larsks, I have found a solution for that particular situation. It's in the answer below. Anyhow, thank you for the effort, and for a showcase of how that should function in general.
urlator avatar
th flag
Hi larsks, I deleted my answer - you are right, you already answered. Somehow all the time I was thinking that you are deleting from the credentials files, and not config. My mistake. Sorry about that.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.