Skip to content

Instantly share code, notes, and snippets.

View sudoapt-getclean's full-sized avatar

Aaldert van Wijk sudoapt-getclean

  • Alliander
  • Nijmegen
View GitHub Profile

Keybase proof

I hereby claim:

  • I am sudoapt-getclean on github.
  • I am aaldert (https://keybase.io/aaldert) on keybase.
  • I have a public key ASBT6_SHJWWIGPMBf-p2flS15pTRYrKTa2VqSkcTVDR6ZQo

To claim this, I am signing this object:

@sudoapt-getclean
sudoapt-getclean / update.sh
Last active April 5, 2019 09:34
Update Code Example
# Look over the keys in the state
for STATE_ENTRY_KEY in $( terraform state list | grep aws_iam_access_key ); do
# Read the actual values for the key
KEY_ENTRY="$( terraform state show ${STATE_ENTRY_KEY} )"
AWS_USERNAME="$( echo "${KEY_ENTRY}" | grep "user" | sed -e "s/user.*= //" )"
AWS_KEY_ID="$( echo "${KEY_ENTRY}" | grep "id" | sed -e "s/id.*= //" )"
AWS_KEY_SECRET="$( echo "${KEY_ENTRY}" | grep "secret" | sed -e "s/secret.*= //" )"
echo "==> Processing ${AWS_USERNAME}"
for STATE_ENTRY_KEY in $( terraform state list | grep aws_iam_access_key ); do
# sed substitutes the [0] notation used by terraform state with the .0 notation used by taint
terraform taint "$( echo ${STATE_ENTRY_KEY} | sed "s/\[/\\./g" | sed "s/\]//g" )"
done
resource "gitlab_group_variable" "aws_acces_key_id" {
group = "${gitlab_group.gateway.id}"
key = "AWS_ACCESS_KEY_ID"
value = "${aws_iam_access_key.bot.id}"
protected = "true"
}