Skip to content
Snippets Groups Projects
Commit fb9d081c authored by Diaz de Arcaya Serrano, Josu's avatar Diaz de Arcaya Serrano, Josu
Browse files

Initial commit

parents
No related branches found
No related tags found
No related merge requests found
# hello-terraform
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.27"
}
}
}
provider "aws" {
profile = "default"
region = "us-west-2"
}
resource "aws_instance" "server0" {
ami = "ami-0ca5c3bd5a268e7db"
instance_type = "t2.micro"
tags = {
Name = "hello-terraform"
}
}
#!/bin/bash
# A POSIX variable
OPTIND=1 # Reset in case getopts has been used previously in the shell.
usage="usage: landing-script.sh [-h] [-i] [-a] [-d]
This script serves as the entrypoint for the IEM
arguments:
-h show this help message and exit
-i init configuration
-a create or update infrastructure
-d destroy infrastructure"
init() {
terraform init
}
apply() {
terraform apply -auto-approve
}
destroy() {
terraform destroy -auto-approve
}
while getopts "h?iad" opt; do
case "$opt" in
h|\?)
echo "$usage"
exit 0
;;
i) init
;;
a) apply
;;
d) destroy
;;
esac
done
output "instance_server0_ip" {
description = "Public IP address of the EC2 instance"
value = aws_instance.server0.public_ip
}
run.sh 0 → 100755
#!/bin/bash
terraform init
terraform apply -auto-approve
terraform destroy -auto-approve
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment