Last active
March 17, 2021 09:46
-
-
Save CorentinDy/14c87000a79720a29edec3993b7c2bde to your computer and use it in GitHub Desktop.
local-exec #terraform
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "null_resource" "init_aws" { | |
triggers = { | |
always_run = timestamp() | |
} | |
provisioner "local-exec" { | |
command = "apk add build-base python3-dev python3 libffi-dev libressl-dev groff bash git gettext curl && curl -O \"https://bootstrap.pypa.io/get-pip.py\" && python3 get-pip.py && pip install --user --upgrade awscli" | |
} | |
depends_on = [aws_elasticache_replication_group.main] | |
} | |
resource "null_resource" "create_redis_users" { | |
triggers = { | |
always_run = timestamp() | |
} | |
for_each = var.redis_user_and_acl | |
provisioner "local-exec" { | |
command = format("export AWS_DEFAULT_REGION=%s && export PATH=$HOME/.local/bin:$PATH && aws elasticache create-user --user-id \"%s\" --user-name default --passwords \"%s\" --engine redis --access-string \"%s\" && sleep 1m", var.aws_region, each.value.user , "1234568791012456" ,each.value.acl) | |
} | |
depends_on = [null_resource.init_aws] | |
} | |
resource "null_resource" "create_redis_user_group" { | |
triggers = { | |
always_run = timestamp() | |
} | |
for_each = var.redis_user_and_acl | |
# for_each = { for data in var.redis_user_and_acl : data.user => name} | |
provisioner "local-exec" { | |
command = format("export AWS_DEFAULT_REGION=%s && export PATH=$HOME/.local/bin:$PATH && aws elasticache create-user-group --user-group-id default-group --engine redis --user-ids \"%s\" && sleep 1m ", var.aws_region, each.value.user) | |
} | |
depends_on = [null_resource.create_redis_users, null_resource.init_aws] | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment