Sed command not replacing a string in terraform file

I am using bash script to replace a string in a terraform file but it's not working.

My bash script is like

name='rajjnew'
    sed -i "s/\"aws_ec2_key_name\" { default = \"rajj\" }/\"aws_ec2_key_name\" { default = \"$name\" }/g" variables.tf

and my variables.tf file is like

variable "aws_ec2_key_name" { default = "rajj" }


Read more here: https://stackoverflow.com/questions/64899870/sed-command-not-replacing-a-string-in-terraform-file

Content Attribution

This content was originally published by tempaccount as at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: