I was installing openshift 4.4.9 on my AWS Cluster using Installer Provisioned Infrastructure (IPI), I wasn't successful to spin up my openshift cluster on AWS. Because of below error.
INFO Creating infrastructure resources...
ERROR
ERROR Error: Error creating IAM instance profile ocp4-925gm-bootstrap-
profile: EntityAlreadyExists:
Instance Profile ocp4-925gm-bootstrap-profile already exists.
ERROR status code: 409, request id: b6918967-774c-44c1-8b92-02ac7388f87c
ERROR
ERROR on ../../../tmp/openshift-install-584826335/bootstrap/main.tf line 46, in resource
"aws_iam_instance_profile" "bootstrap":
ERROR 46: resource "aws_iam_instance_profile" "bootstrap" {
ERROR Error: Error creating IAM instance profile ocp4-925gm-worker-profile: EntityAlreadyExists:
Instance Profile ocp4-925gm-worker-profile already exists.
ERROR status code: 409, request id: 3b5d2b9c-28fe-4c95-b622-7a80af45dfb6
ERROR
ERROR on ../../../tmp/openshift-install-584826335/iam/main.tf line 5, in resource
"aws_iam_instance_profile" "worker":
ERROR 5: resource "aws_iam_instance_profile" "worker" {
ERROR Error: Error creating IAM instance profile ocp4-925gm-master-profile: EntityAlreadyExists:
Instance Profile ocp4-925gm-master-profile already exists.
ERROR status code: 409, request id: 072d86e1-3508-4d59-a6ab-2ed647251056
ERROR
ERROR on ../../../tmp/openshift-install-584826335/master/main.tf line 9, in
resource
"aws_iam_instance_profile" "master":
ERROR 9: resource "aws_iam_instance_profile" "master" {
FATAL failed to fetch Cluster: failed to generate asset "Cluster": failed to
create cluster: failed
to apply using Terraform
Solution to Fix
Manually deletion is recommended in this case.
List your roles and then apply delete to the instance profiles.
$ aws iam list-roles
$ aws --region=<region-name> iam delete-instance-profile --instance-profile-name <profile_name>
Example Given Below
$ aws --region=us-east-1 iam delete-instance-profile --instance-profile-name ocp4-925gm-master-profile
$ aws --region=us-east-1 iam delete-instance-profile --instance-profile-name ocp4-925gm-worker-profile