Created
August 13, 2020 06:39
-
-
Save khushi20218/5fae3acc04409bcf4334770b2ff4adc7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_instance" "wordpress" { | |
ami = "ami-0732b62d310b80e97" | |
instance_type = "t2.micro" | |
subnet_id = aws_subnet.pub_subnet1.id | |
security_groups = [aws_security_group.tf_wp_sg.id] | |
key_name = "key1" | |
tags = { | |
Name = "wordpress" | |
} | |
} | |
resource "null_resource" "wp-sql-connection" { | |
depends_on = [ | |
aws_instance.mysql | |
] | |
connection { | |
type = "ssh" | |
user = "ec2-user" | |
private_key = file("C:/Users/Daksh jain/Desktop/IIEC_VIMAL DAGA/6. HYBRID CLOUD/key1.pem") | |
host = aws_instance.wordpress.public_ip | |
} | |
provisioner "remote-exec" { | |
inline = [ | |
"sudo su <<END", | |
"yum install docker httpd -y", | |
"systemctl enable docker", | |
"systemctl start docker", | |
"docker pull wordpress:5.1.1-php7.3-apache", | |
"sleep 30", | |
"docker run -dit -e WORDPRESS_DB_HOST=${aws_instance.mysql.private_ip} -e WORDPRESS_DB_USER=wpuser -e WORDPRESS_DB_PASSWORD=wppass -e WORDPRESS_DB_NAME=wpdb -p 80:80 wordpress:5.1.1-php7.3-apache", | |
"END", | |
] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment