As I've been working with AWS recently, I find myself struggling to do really simple things. Newbie errors. I recently documented my struggles with configuring an Amplify backend and wanted to return to the subject to reveal another issue that I had: changing the default profile.
Before beginning, I wanted to say a bit about what Amplify is. According to AWS's description:
AWS Amplify is a set of products and tools that enables mobile and front-end web developers to build and deploy secure, scalable full stack applications, powered by AWS. With Amplify, you can configure app backends in minutes, connect them to your app in just a few lines of code, and deploy static web apps in three steps.
In short, Amplify is a quick way to set up a backend. I'm using it in a shared project to run the backend of a React application.
Now my struggle: I was running a shell script in the application to create an account in the backend of the web application, and the script required that I call on my AWS profile alias. When you configure an AWS account the first time, the profile name will default to "default." For some reason, the script did not like the name 'default', even when assigned to an environment variable.
AWS does not have the clearest documentation for how to change the name of a profile, but it turns out to be pretty easy. If you have configured your settings correctly, you should have two local files that contain your account settings such as API key: ~/.aws/config
and ~/.aws/credentials
. If you're in an editor like VS Code, these might not be visible so just run open
before the path and you'll get something like a .rtf with your AWS configuration. You'll notice that in both files, account settings are listed and they having a header set in brackets, which contains the profile name. For the profile named default, simply delete the word default and assign the name you want. It must match in the two files. Save the two files. And that's it.
If you want to preserve this account as the default one, just remember the alias you have given the profile run the command export AWS_PROFILE=<my_profile>
(with acting as the name of your profile). You can perform this step whenever you want to change the default AWS profile. And that it. Three simple steps to change the name of your AWS default profile.
Top comments (0)