I've recently updated our modufle configuration to change the terraform ressource name
module "runner_c5_xlarge_eu_west_3_b" {
source = "npalm/gitlab-runner/aws"
version = "4.1.0"
aws_region = "eu-west-3"
aws_zone = "b"
# Here we set a different environment than the previous (and other runner modules)
# because every resource created by this module is indexed by this variable
# so in order not to have name conflicts, we need a different environment for
# each runner
environment = "Service-4"
....
}
module "runner_c5_large_eu_west_3_b" {
Error: Error import KeyPair: InvalidKeyPair.Duplicate: The keypair 'Service-4-gitlab-runner' already exists.
status code: 400, request id: f132a471-57ea-4106-97bb-5e8beb85a0a5
on .terraform/modules/runner_c5_large_eu_west_3_b/npalm-terraform-aws-gitlab-runner-31b0bab/main.tf line 1, in resource "aws_key_pair" "key":
1: resource "aws_key_pair" "key" {
Error: Error creating IAM Role Service-4-instance-role: EntityAlreadyExists: Role with name Service-4-instance-role already exists.
status code: 409, request id: cbb8b28e-ca34-11e9-b038-abe555558e62
on .terraform/modules/runner_c5_large_eu_west_3_b/npalm-terraform-aws-gitlab-runner-31b0bab/main.tf line 288, in resource "aws_iam_role" "instance":
288: resource "aws_iam_role" "instance" {
Error: Error creating IAM policy Service-4-docker-machine: EntityAlreadyExists: A policy called Service-4-docker-machine already exists. Duplicate names are not allowed.
status code: 409, request id: ca24f337-ca34-11e9-aaa5-3d97689ee397
on .terraform/modules/runner_c5_large_eu_west_3_b/npalm-terraform-aws-gitlab-runner-31b0bab/main.tf line 302, in resource "aws_iam_policy" "instance_docker_machine_policy":
302: resource "aws_iam_policy" "instance_docker_machine_policy" {
Error: Error creating IAM Role Service-4-docker-machine-role: EntityAlreadyExists: Role with name Service-4-docker-machine-role already exists.
status code: 409, request id: cc06365f-ca34-11e9-ae4f-bb716bff761d
on .terraform/modules/runner_c5_large_eu_west_3_b/npalm-terraform-aws-gitlab-runner-31b0bab/main.tf line 331, in resource "aws_iam_role" "docker_machine":
331: resource "aws_iam_role" "docker_machine" {
I guess it happens because of a ordering problem in the order the resources are deleted / recreated ?