Created
January 16, 2021 09:15
-
-
Save iamtheindian/50caa16377dcc9a8d1768845cb9d55fa 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
#combined use of remote and local execution | |
resource "null_resource" "nl1" { | |
depends_on = [ aws_volume_attachment.ebs_att,aws_s3_bucket.b,aws_cloudfront_distribution.s3_distribution ] | |
#sending local data to remote instance using scp | |
provisioner "local-exec" { | |
command = "chmod 400 /root/HybridCloud/Terraform/MyKeyPair.pem && scp -o StrictHostKeyChecking=no -r -i /root/HybridCloud/Terraform/MyKeyPair.pem /root/HybridCloud/Terraform/php ec2-user@${aws_instance.webos.public_dns}:/home/ec2-user" | |
} | |
connection { | |
type = "ssh" | |
user = "ec2-user" | |
private_key = data.local_file.key_file.content | |
host = aws_instance.webos.public_ip | |
} | |
provisioner "remote-exec" { | |
inline = [ | |
"efs_id= ${aws_efs_file_system.efs_file.id} " , | |
"sudo mount -t efs $efs_id:/ /var/www/html", | |
"sudo rm -rf /var/www/html/*", | |
"sudo mv -f /home/ec2-user/php/* /var/www/html/" | |
] | |
} | |
provisioner "local-exec" { | |
command = "curl ${aws_instance.webos.public_ip} " | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment