Recently we been working on release pipelines with infrastructure as code for AWS (further blogs to follow!). After clearing down an environment and attempting a redeploy it would error to say the instance profile aready exisited. When checking the AWS portal there was no mention of this to delete and so turned to CLI.

Install AWS CLI: https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-windows.html

* I did have an issue where setting the path didnt work, so instead i changed directory to the path and used the aws2.exe instead of aws.

Configure authentication:
aws2.exe configure

Access key ID
<You can get this from: organisation name, then on “My Security Credentials”. Click on “Create New Access Key” and then copy down the data that is displayed.>

Secret access key
<You can get this from: organisation name, then on “My Security Credentials”. Click on “Create New Access Key” and then copy down the data that is displayed.>

Default region name [None]:
eu-west-2

Default output format [None]:

List instance profiles:
aws2.exe iam list-instance-profiles

Delete instance profile:
aws2.exe iam delete-instance-profile –instance-profile-name <name of profile to be deleted>

Hope it helps!

About the author