{"id":18299632,"url":"https://github.com/containersolutions/terraform-examples","last_synced_at":"2025-04-05T13:35:06.021Z","repository":{"id":38193873,"uuid":"352364838","full_name":"ContainerSolutions/terraform-examples","owner":"ContainerSolutions","description":"Simple and idiomatic examples of various Terraform functions and features.","archived":false,"fork":false,"pushed_at":"2023-06-15T12:43:03.000Z","size":735,"stargazers_count":160,"open_issues_count":45,"forks_count":52,"subscribers_count":13,"default_branch":"main","last_synced_at":"2024-08-03T22:19:34.241Z","etag":null,"topics":["terraform"],"latest_commit_sha":null,"homepage":"https://containersolutions.github.io/terraform-examples/","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/ContainerSolutions.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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}},"created_at":"2021-03-28T15:24:37.000Z","updated_at":"2024-03-10T16:49:24.000Z","dependencies_parsed_at":"2024-01-14T20:34:33.771Z","dependency_job_id":null,"html_url":"https://github.com/ContainerSolutions/terraform-examples","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ContainerSolutions%2Fterraform-examples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ContainerSolutions%2Fterraform-examples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ContainerSolutions%2Fterraform-examples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ContainerSolutions%2Fterraform-examples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ContainerSolutions","download_url":"https://codeload.github.com/ContainerSolutions/terraform-examples/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223192565,"owners_count":17103564,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["terraform"],"created_at":"2024-11-05T15:09:41.577Z","updated_at":"2024-11-05T15:09:42.235Z","avatar_url":"https://github.com/ContainerSolutions.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# terraform-examples\n\nA reference repository of Terraform with canonical and as-simple-as-possible demonstrations of Terraform functionality and features.\n\nSee here for a searchable front-end: https://containersolutions.github.io/terraform-examples/\n\n## Why?\n\nAt Container Solutions we find we regularly need chunks of Terraform to demonstrate something specific, such as:\n\n- A simple EC2 instance\n\n- A bespoke VPC\n\n- A Windows EC2 instance with an EBS volume\n\nThis might be to do a basic test of something, find an example to tinker with, or send to someone to get them going.\n\n## Usage\n\nTo help get started with these examples, there are scripts available in `bin` and in local folders.\n\nHere's an example run:\n\n```\n$ git clone https://github.com/ContainerSolutions/terraform-examples\n$ cd terraform-examples\n$ cd aws/aws_vpc\n$ ./run.sh\nInput AWS_ACCESS_KEY_ID\nKEY\nInput AWS_SECRET_ACCESS_KEY\n\u003csecret\u003e\n...\n```\n\nIf you want to skip the manual key/id inputs, then export them.\n\nSee `bin/README.md` for more information.\n\n## Where is...?\n\nIf you want to look for a specific example, try the [index](INDEX.md).\n\n## Sections\n\nThe code is generally divided up by provider, then resource, then whatever the example illustrates, eg `local/null_resource/for_each`, or `aws/aws_instance/remote-exec/inline`.\n\nOther basic language features may be illustrated in their own folders, eg `outputs/local_file/module`.\n\n## Principles\n\nThe examples seek to be:\n\n- As simple as possible to illustrate the functionality\n\n- Self-contained (ie limited to one `.tf` file)\n\n- Clear (eg resource names are verbose and unambiguous)\n\n## Conventions\n\n- Naming examples:\n  - `simple` - for minimal functionality demonstration\n  - `\u003cfunctionality\u003e` - when demonstrating something more than minimal\n  - directory structure: `\u003cprovider\u003e/\u003cresource_type\u003e/\u003cexample_name\u003e`\n\n- Where it makes sense, items that can be changed are prefaced with `changeme_`\n\n- In general, underscores are used in Terraform names over dashes\n\n- Naming Terraform resources, data, and variables:\n  - use only lower case letters, numbers, and underscore\n  - names should be unique between all examples (but across resources items only if a resource; data items only if data, etc)\n  - prefixed with:  `changeme_\u003cexample_name\u003e_`\n\n- `name =` attribute within the resource:\n  - use only lower case letters, numbers, and dash\n  - same as resource name, but with: `s/_/-/g`\n\n- For help with automated testing\n  - where possible, add some way to enable 'left-over' resources to be cleaned up, eg provider `default_tags` of `cs_terraform_examples` in AWS provider blocks\n\n- Add inline documentation for each Terraform code block\n  - `# Summary:` – 1-line summary of what this example does\n  - `# Documentation:` – add link to documentation before each block (terraform, provider, variable, resource, etc.)\n  - `# Explanation:` – add only where some extra explanation is needed\n\n## Contributing\n\nContributions to terraform-examples project are welcome. You can find detailed information about [contributing here](CONTRIBUTING.md).\n\n## GitHub Actions Workflow\n\nOn every commit/push, the following tests run on all branches:\n\n- A `tflint` on all files ending with `tf`\n\n- A `terraform validate` on all\n\n- A series of checks to test the code against standards\n\n\nUsing slash command /test, a maintainer can run Cloud Testing jobs. \nThis includes:\n\n- All AWS provider examples are run against an AWS account\n\n- All GCP provider examples are run against a GCP account\n\n- All Linode provider examples are run against a Linode account\n\n- All DigitalOcean provider examples are run against a DigitalOcean account\n\n- All 'local' provider examples are run locally on the GitHub Actions runner\n\nCloud Environment tests are long and/or cost money and they won't work without the necessary auth information being set up correctly. \n\nThe auth information for the provider accounts are stored in secrets in the repository, accessible to the admin.\n\n\nSlash commands can be used to approve/merge the PR, '/approve' or '/merge'.\n\nThe Flow:\n\n- PR is opened\n\n- Contributor commits/pushes on-demand and triggers the Statis Tests\n\n- Once ready, and maintainer runs the Full-CI, which includes Cloud Tests '/test'\n\n- If everything goes well, the maintainer uses the command '/approve' to mark as reviewed/approve\n\n- The last step, after everything is checked, '/merge' to perform the merge to the main branch\n\n\nNote: All the slash commands are performed by Github Actions BOT with GITHUB_TOKEN\n\n\n### Forcing tests\n\nYou can force a test for a given provider (on `main` branch only) by adding a `.forcetest` file to the relevant folder.\n\nFor example, if you want to ensure that the aws tests run, then add an empty file in `aws/.forcetest`. On a successfully completed test run, these files are removed as part of the 'success commit' in the github action workflow.\n\n## Maintainer Information\n\nFor information for maintainers of this repository at ContainerSolutions, see [maintainers](MAINTAINERS.md)\n\n## Sources / Thanks To\n\n[Learn Terraform The Hard Way](https://leanpub.com/learnterraformthehardway)\n[Slash Commands](https://github.com/marketplace/actions/slash-commands)\n\n## Other Examples\n\n[Immutable Cluster Using Packer and Ansible on AWS](https://github.com/bluebrown/immutable-cluster)\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcontainersolutions%2Fterraform-examples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcontainersolutions%2Fterraform-examples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcontainersolutions%2Fterraform-examples/lists"}