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

    sed -i "s/\"aws_ec2_key_name\" { default = \"rajj\" }/\"aws_ec2_key_name\" { default = \"$name\" }/g"

and my file is like

variable "aws_ec2_key_name" { default = "rajj" }

Read more here:

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: