Skip to content

Instantly share code, notes, and snippets.

@naumvd95
Last active April 21, 2021 12:53
Show Gist options
  • Save naumvd95/00bdcd5ef40edc50da05b58c84950f1d to your computer and use it in GitHub Desktop.
Save naumvd95/00bdcd5ef40edc50da05b58c84950f1d to your computer and use it in GitHub Desktop.
Generate random SG rule names in terraform
# we already have entities like " resource "openstack_networking_secgroup_rule_v2" "offline_secgroup_rule_extra_" {}"
# and want to generate uniq postfixes for them
for lineNum in $(grep -Rin "rule_extra" main.tf | cut -f2 -d:); do sed -i '' "${lineNum}s/rule_extra_/rule_extra_$(openssl rand -hex 3)/" main.tf; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment