Code Monkey home page Code Monkey logo

Comments (4)

brikis98 avatar brikis98 commented on June 2, 2024

Did you inline that code within a Terraform file (.tf)? If so, you need to escape the dollar sign, or it gets interpreted as Terraform interpolation. To escape it, use a double dollar sign ($$):

declare instance_address = $$(curl http://169.254.169.254/latest/meta-data/public-hostname)

from terraform-up-and-running-code.

payamzowghi avatar payamzowghi commented on June 2, 2024

no, I use in my User Data bash script(bootstrap WordPress), not my terraform file.in my bash script, I need the public DNS of my instance.I ran ASG and Launch resources to create a cluster.unfortunately, I couldn't find any attributes relevant to the public DNS in ASG and Launch resources.that's why I want to use hostname metadata.
1-this is my template file:
data "template_file" "user_data" {
template = "${file("files/wordpress_ubuntu.sh")}"

vars {
db_address = "${aws_db_instance.wordpress-db.address}"
db_port = "${aws_db_instance.wordpress-db.port}"
db_user = "${aws_db_instance.wordpress-db.username}"
db_password = "${aws_db_instance.wordpress-db.password}"
}
}
2-part of my bash file(wordpress_ubuntu.sh) as bootstrap
declare database_address = ${db_address}
declare database_port = ${db_port}
declare database_user = ${db_user}
declare database_password = ${db_password}

sudo wget http://s3.amazonaws.com/ec2metadata/ec2-metadata
sudo chmod u+x ec2-metadata
sudo cp ec2-metadata /usr/bin/
declare instance_address = $(curl http://169.254.169.254/latest/meta-data/pu

#update your system
sudo apt-get update && sudo apt-get upgrade -y

from terraform-up-and-running-code.

brikis98 avatar brikis98 commented on June 2, 2024

Hm, I'm not sure what that is. Try SSHing to the instance and running your script manually. Perhaps that'll make it clearer what's going on.

from terraform-up-and-running-code.

brikis98 avatar brikis98 commented on June 2, 2024

No response in ~3 years. Closing.

from terraform-up-and-running-code.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.