terraform-community-modules / tf_aws_elasticsearch

[DEPRECATED] Use https://github.com/terraform-aws-modules/terraform-aws-opensearch
MIT License
79 stars 97 forks source link

Service linked role #14

Closed whyman closed 5 years ago

whyman commented 5 years ago

Hey,

If using this module on virgin account you will get an error as the service linked role doesnt exist.

To create use:

resource "aws_iam_service_linked_role" "es" {
  aws_service_name = "es.amazonaws.com"
}

The problem comes if you are trying to use the above more than once per account, you will get a conflict.

Any suggestions?

newmie commented 5 years ago

There is some detailed discussion on the issue here: https://github.com/terraform-providers/terraform-provider-aws/issues/5218

There is another terraform elasticsearch module and their fix was to make creation of the service-role optional: https://github.com/cloudposse/terraform-aws-elasticsearch/issues/5

Depending on your circumstances you could do a similar fix to above:

resource "aws_iam_service_linked_role" "es" {
  count = "${var.service_role_count}"
  aws_service_name = "es.amazonaws.com"
}

If like me your in a situation where you are trying to deploy a microservice and it's not appropriate for it to take ownership of creating this role, then another option is to deploy it as part of a base/platform/shared infrastructure deployment.

antonbabenko commented 5 years ago

This has been fixed in #22, use v0.7.0 to get this fixed.