├── terraform-labs ├── aws-dynamodb-items │ ├── main.tf │ ├── outputs.tf │ ├── provider.tf │ └── variables.tf ├── localstack-s3-ecommerce │ ├── main.tf │ ├── outputs.tf │ ├── provider.tf │ └── variables.tf ├── docker-terraform-helloworld │ ├── main.tf │ ├── outputs.tf │ └── variables.tf └── .DS_Store ├── ejemplos ├── 03-aws-s3-localstack │ ├── terraform.tfvars │ ├── output.tf │ ├── main.tf │ ├── variables.tf │ └── provider.tf ├── 04-docker-nginx-html │ ├── output.tf │ ├── main.tf │ └── index.html ├── 02-local-condicionales │ └── main.tf └── 01-local-simple │ └── main.tf └── README.md /terraform-labs/aws-dynamodb-items/main.tf: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------------- /terraform-labs/aws-dynamodb-items/outputs.tf: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------------- /terraform-labs/aws-dynamodb-items/provider.tf: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------------- /terraform-labs/aws-dynamodb-items/variables.tf: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------------- /terraform-labs/localstack-s3-ecommerce/main.tf: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------------- /terraform-labs/docker-terraform-helloworld/main.tf: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------------- /terraform-labs/localstack-s3-ecommerce/outputs.tf: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------------- /terraform-labs/localstack-s3-ecommerce/provider.tf: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------------- /terraform-labs/localstack-s3-ecommerce/variables.tf: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------------- /terraform-labs/docker-terraform-helloworld/outputs.tf: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------------- /terraform-labs/docker-terraform-helloworld/variables.tf: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------------- /ejemplos/03-aws-s3-localstack/terraform.tfvars: -------------------------------------------------------------------------------- 1 | bucket_name = "demo.s3.workshop" 2 | environment = "dev" -------------------------------------------------------------------------------- /ejemplos/03-aws-s3-localstack/output.tf: -------------------------------------------------------------------------------- 1 | output "idbucket" { 2 | value = aws_s3_bucket.example.arn 3 | } -------------------------------------------------------------------------------- /terraform-labs/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roxsross/workshop-tfroxs/HEAD/terraform-labs/.DS_Store -------------------------------------------------------------------------------- /ejemplos/04-docker-nginx-html/output.tf: -------------------------------------------------------------------------------- 1 | output "nginx_access_url" { 2 | value = "http://localhost:8080" 3 | description = "URL para acceder al servidor Nginx" 4 | } -------------------------------------------------------------------------------- /ejemplos/03-aws-s3-localstack/main.tf: -------------------------------------------------------------------------------- 1 | resource "aws_s3_bucket" "example" { 2 | bucket = var.bucket_name 3 | 4 | tags = { 5 | Name = var.bucket_name 6 | Environment = var.environment 7 | } 8 | } -------------------------------------------------------------------------------- /ejemplos/03-aws-s3-localstack/variables.tf: -------------------------------------------------------------------------------- 1 | variable "bucket_name" { 2 | description = "The name of the S3 bucket" 3 | type = string 4 | } 5 | 6 | variable "environment" { 7 | description = "The environment for the S3 bucket" 8 | type = string 9 | } 10 | 11 | variable "environment" { 12 | description = "The environment for the S3 bucket" 13 | type = string 14 | } -------------------------------------------------------------------------------- /ejemplos/03-aws-s3-localstack/provider.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_providers { 3 | aws = { 4 | source = "hashicorp/aws" 5 | version = "5.97.0" 6 | } 7 | } 8 | } 9 | 10 | provider "aws" { 11 | region = "us-east-1" 12 | access_key = "fake" 13 | secret_key = "fake" 14 | ######solo para localstack 15 | s3_use_path_style = true 16 | skip_credentials_validation = true 17 | skip_metadata_api_check = true 18 | skip_requesting_account_id = true 19 | 20 | endpoints { 21 | s3 = "http://localhost:4566" 22 | } 23 | } -------------------------------------------------------------------------------- /ejemplos/02-local-condicionales/main.tf: -------------------------------------------------------------------------------- 1 | provider "local" { 2 | # Configuration options 3 | } 4 | 5 | variable "files" { 6 | type = map(object({ 7 | content = string 8 | create = bool 9 | })) 10 | default = { 11 | "config1" = { 12 | content = "contenido 1" 13 | create = true 14 | } 15 | "config2" = { 16 | content = "contenido 2" 17 | create = true 18 | } 19 | "config3" = { 20 | content = "contenido 3" 21 | create = true 22 | } 23 | } 24 | } 25 | 26 | resource "local_file" "configs" { 27 | for_each = { 28 | for name, file in var.files : 29 | name => file 30 | if file.create == true 31 | } 32 | 33 | content = each.value.content 34 | filename = "${each.key}.txt" 35 | } -------------------------------------------------------------------------------- /ejemplos/04-docker-nginx-html/main.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_providers { 3 | docker = { 4 | source = "kreuzwerker/docker" 5 | version = "~> 3.0.2" 6 | } 7 | local = { 8 | source = "hashicorp/local" 9 | version = "~> 2.4.0" 10 | } 11 | } 12 | required_version = ">= 1.0.0" 13 | } 14 | 15 | provider "docker" {} 16 | provider "local" {} 17 | 18 | data "local_file" "index_html" { 19 | filename = "${path.module}/index.html" 20 | } 21 | 22 | resource "docker_container" "nginx" { 23 | name = "nginx-terraform" 24 | image = "nginx:alpine" 25 | 26 | ports { 27 | internal = 80 28 | external = 8080 29 | } 30 | 31 | upload { 32 | file = "/usr/share/nginx/html/index.html" 33 | content = data.local_file.index_html.content 34 | } 35 | } 36 | 37 | -------------------------------------------------------------------------------- /ejemplos/01-local-simple/main.tf: -------------------------------------------------------------------------------- 1 | provider "local" { 2 | # Configuración del proveedor local 3 | } 4 | 5 | provider "random" { 6 | # Configuración del proveedor random 7 | } 8 | 9 | variable "contenido" { 10 | type = string 11 | default = "Hola Mundo2" 12 | } 13 | 14 | resource "random_string" "random" { 15 | length = 4 16 | special = false 17 | numeric = true 18 | upper = false 19 | } 20 | 21 | resource "local_file" "demo1" { 22 | content = var.contenido 23 | filename = "product-${random_string.random.id}.txt" 24 | } 25 | 26 | resource "local_file" "demo2" { 27 | content = var.contenido 28 | filename = "product2-${random_string.random.id}.txt" 29 | } 30 | 31 | output "nombre_archivo_demo2" { 32 | value = local_file.demo2.filename 33 | } 34 | 35 | output "nombre_archivo_demo1" { 36 | value = local_file.demo1.filename 37 | } 38 | -------------------------------------------------------------------------------- /ejemplos/04-docker-nginx-html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 |Esta página fue creada y desplegada usando Terraform, una herramienta de infraestructura como código que permite crear, cambiar y versionar infraestructura de forma segura y eficiente.
150 |
176 |
177 | ## Contactos
178 |
179 | Me puedes encontrar en las siguientes plataformas:
180 |
181 | - [Hashnode](https://blog.295devops.com)
182 | - [Dev.to](https://dev.to/roxsross)
183 | - [Twitter](https://twitter.com/roxsross)
184 | - [LinkedIn](https://www.linkedin.com/in/roxsross/)
185 | - [Instagram](https://www.instagram.com/roxsross/)
186 | - [YouTube](https://www.youtube.com/channel/UCa-FcaB75ZtqWd1YCWW6INQ)
187 |
--------------------------------------------------------------------------------