{"id":20016635,"url":"https://github.com/rafaelclaumann/some-terraform-study","last_synced_at":"2026-05-01T22:35:40.413Z","repository":{"id":45341343,"uuid":"420086197","full_name":"RafaelClaumann/some-terraform-study","owner":"RafaelClaumann","description":"Repositório para armazenar os laboratórios de terraform.","archived":false,"fork":false,"pushed_at":"2023-07-27T12:44:43.000Z","size":72,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-02T03:14:19.408Z","etag":null,"topics":["amazon","aws","bash","cloud","hashicorp","hcl","iac","terraform"],"latest_commit_sha":null,"homepage":"","language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RafaelClaumann.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-10-22T12:15:03.000Z","updated_at":"2023-07-27T13:00:07.000Z","dependencies_parsed_at":"2025-01-12T15:42:38.690Z","dependency_job_id":"665d8344-1909-426b-8ac0-f1f512c5d162","html_url":"https://github.com/RafaelClaumann/some-terraform-study","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/RafaelClaumann/some-terraform-study","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RafaelClaumann%2Fsome-terraform-study","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RafaelClaumann%2Fsome-terraform-study/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RafaelClaumann%2Fsome-terraform-study/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RafaelClaumann%2Fsome-terraform-study/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RafaelClaumann","download_url":"https://codeload.github.com/RafaelClaumann/some-terraform-study/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RafaelClaumann%2Fsome-terraform-study/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32515838,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"online","status_checked_at":"2026-05-01T02:00:05.856Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["amazon","aws","bash","cloud","hashicorp","hcl","iac","terraform"],"created_at":"2024-11-13T08:12:22.166Z","updated_at":"2026-05-01T22:35:40.386Z","avatar_url":"https://github.com/RafaelClaumann.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# some-terraform-study\n\nRepositório utilizado para armazenar laboratórios de Terraform.\n- [aws-network](https://github.com/RafaelClaumann/some-terraform-study/tree/main/aws-network)\n- [aws-sqs-sns](https://github.com/RafaelClaumann/some-terraform-study/tree/main/aws-sqs-sns)\n- [aws-vpc](https://github.com/RafaelClaumann/some-terraform-study/tree/main/aws-vpc)\n- [do-basico-a-modulos](https://github.com/RafaelClaumann/some-terraform-study/tree/main/do-basico-a-modulos)\n- [lambda-alb](https://github.com/RafaelClaumann/some-terraform-study/tree/main/lambda-alb) \n- [terraform-101](https://github.com/RafaelClaumann/some-terraform-study/tree/main/terraform-101)\n\n## Guias\n- [Install Terraform (*5:22*) \u0026 AWS CLI (*14:35*)](https://youtu.be/bYvdJKTwx_I?t=874)\n- Exemplo do arquivo **~/.aws/credentials**\n```bash\n  [terraform-study]\n  aws_access_key_id = \u003cYOUR_ACCESS_KEY\u003e\n  aws_secret_access_key = \u003cYOUR_SECRET_KEY\u003e\n```\n\n\n## 💻 Comandos Basicos\n``` bash\nterraform init  # download do(s) provider(s)\nterraform fmt  # formatar o código\nterraform plan  # planejar execução\nterraform apply  # implantar infraestrutura\nterraform destroy  # destruir infraestrutura\n```\n\n\n## :bricks: Blocos Basicos\n\n### Provider\nBloco de conexão com o provider(provedor), por exemplo AWS.\n``` hcl\nprovider \"aws\" {\n  region  = \"us-east-1\"\n  profile = \"awsrafael\" # utilizando profile do arquivo ~/.aws/credentials\n}\n```\n\n### Resource\nBloco utilizado para criar recursos disponibilizados pelo provider. \u003cbr\u003e\nO nome **\"server\"** pode ser utilizado para referenciar o recurso em outros arquivos terraform.\n``` hcl\n# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/instance\nresource \"aws_instance\" \"server\" {\n  ami           = data.aws_ami.ubuntu.image_id  # referencia o bloco data\n  instance_type = \"t2.micro\"\n}\n```\n\n### Variable\nBloco usado para declarar variáveis. Essas variáveis podem ser acessadas em outros arquivos terraform e devem ser preenchidas na execução dos comandos plan e/ou apply.\u003cbr\u003e\n``` hcl\nvariable \"region\" {\n  type        = string # numer, boolean, list, map\n  default     = \"us-east-1\"\n  description = \"define instance region\"\n}\n\n# acessing_list: var.list_example[0]\nvariable \"list_example\" {\n  type        = list \n  description = \"list example varible\"\n  default     = [\"first_item\", \"second_item\", \"third_item\"]\n}\n\n# acessing_map: var.amis[\"us-east-1\"]\nvariable \"amis\" {\n  type    = map\n  default = {\n    \"us-east-1\" = \"ami-b374d5a5\"\n    \"us-west-2\" = \"ami-4b32be2b\"\n  }\n}\n```\n### Output\nBloco útil para exibir informações na tela após a criação dos recursos, seu uso é bastante conveniente para extrair dados dos **resources**.\n\nÉ possível encontrar os **outputs** padrões para cada **resource** na [documentação](https://registry.terraform.io/providers/hashicorp/aws/latest/docs) do provider.\n\nOs nomes **\"public_ip\"** \u0026 **\"instance_region\"** foram escolhidos abitráriamente.\n``` hcl\n# value = resource.resource_name.default_output\noutput \"public_ip\" {\n  value = aws_instance.ubuntu.public_ip\n}\n\noutput \"instance_region\" {\n  value = var.region\n}\n```\n### Data\nBloco utilizado para buscar informações dos recursos existentes no provider em tempo de execução.\n\nO exemplo abaixo mostra um bloco **data** configurado para buscar a versão mais recente de uma **ami** na aws.\n\nO bloco **resouce** dos exemplos anteriores fez referencia ao retorno do bloco **data** mostrado abaixo para definir a imagem usada na instancia EC2.\n``` hcl\ndata \"aws_ami\" \"ubuntu\" {\n  most_recent = true\n\n  filter {\n    name   = \"name\"\n    values = [\"ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*\"]  # nome da ami\n  }\n\n  owners = [\"099720109477\"]  # id da canonical\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frafaelclaumann%2Fsome-terraform-study","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frafaelclaumann%2Fsome-terraform-study","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frafaelclaumann%2Fsome-terraform-study/lists"}