Add terraform examples folder structure#1
Merged
Conversation
Copilot
AI
changed the title
[WIP] Create folder structure for terraform examples
Add terraform examples folder structure
Jul 16, 2026
Owner
|
@copilot the examples would NOT have anything other than azure, can you remove any of the aws type structure? |
There was a problem hiding this comment.
Pull request overview
Bootstraps the repository with a consistent Terraform examples layout (by cloud provider and resource/use-case), plus baseline documentation and ignore rules to support adding more examples over time.
Changes:
- Added a standardized
examples/<provider>/<example>/structure with initial AWS, Azure, and GCP examples (each withmain.tf,variables.tf,outputs.tf,versions.tf,README.md). - Added
modules/as a landing zone for reusable Terraform modules with a starter README. - Updated root
README.mdand added.gitignorefor Terraform artifacts.
Reviewed changes
Copilot reviewed 37 out of 38 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents repo purpose, structure, and the standard example layout/usage flow. |
| .gitignore | Ignores Terraform working directories, state/plan files, and tfvars. |
| modules/README.md | Introduces the intended reusable module area and basic usage guidance. |
| examples/aws/ec2-instance/main.tf | Adds an EC2 instance example using latest Amazon Linux 2 AMI selection. |
| examples/aws/ec2-instance/variables.tf | Defines inputs for the EC2 instance example. |
| examples/aws/ec2-instance/outputs.tf | Exposes basic EC2 outputs. |
| examples/aws/ec2-instance/versions.tf | Pins Terraform/provider constraints and configures the AWS provider. |
| examples/aws/ec2-instance/README.md | Documents the EC2 instance example usage and inputs/outputs. |
| examples/aws/s3-bucket/main.tf | Adds an S3 bucket example with encryption, versioning option, and public access block. |
| examples/aws/s3-bucket/variables.tf | Defines inputs for the S3 bucket example. |
| examples/aws/s3-bucket/outputs.tf | Exposes basic S3 outputs. |
| examples/aws/s3-bucket/versions.tf | Pins Terraform/provider constraints and configures the AWS provider. |
| examples/aws/s3-bucket/README.md | Documents the S3 bucket example usage and inputs/outputs. |
| examples/aws/vpc/main.tf | Adds a VPC example with public/private subnets and routing resources. |
| examples/aws/vpc/variables.tf | Defines inputs for the VPC example. |
| examples/aws/vpc/outputs.tf | Exposes VPC/subnet/IGW outputs. |
| examples/aws/vpc/versions.tf | Pins Terraform/provider constraints and configures the AWS provider. |
| examples/aws/vpc/README.md | Documents the VPC example usage and inputs/outputs. |
| examples/azure/resource-group/main.tf | Adds a basic Azure resource group example. |
| examples/azure/resource-group/variables.tf | Defines inputs for the Azure resource group example. |
| examples/azure/resource-group/outputs.tf | Exposes Azure resource group outputs. |
| examples/azure/resource-group/versions.tf | Pins Terraform/provider constraints and configures the AzureRM provider. |
| examples/azure/resource-group/README.md | Documents the Azure resource group example usage and inputs/outputs. |
| examples/azure/virtual-network/main.tf | Adds a basic Azure VNet + subnet example (including RG creation). |
| examples/azure/virtual-network/variables.tf | Defines inputs for the Azure virtual network example. |
| examples/azure/virtual-network/outputs.tf | Exposes Azure VNet/subnet outputs. |
| examples/azure/virtual-network/versions.tf | Pins Terraform/provider constraints and configures the AzureRM provider. |
| examples/azure/virtual-network/README.md | Documents the Azure virtual network example usage and inputs/outputs. |
| examples/gcp/gke-cluster/main.tf | Adds a basic GKE cluster example. |
| examples/gcp/gke-cluster/variables.tf | Defines inputs for the GKE cluster example. |
| examples/gcp/gke-cluster/outputs.tf | Exposes GKE outputs (with sensitive markings). |
| examples/gcp/gke-cluster/versions.tf | Pins Terraform/provider constraints and configures the Google provider. |
| examples/gcp/gke-cluster/README.md | Documents the GKE cluster example usage and inputs/outputs. |
| examples/gcp/vpc-network/main.tf | Adds a GCP VPC + subnetwork example. |
| examples/gcp/vpc-network/variables.tf | Defines inputs for the GCP VPC network example. |
| examples/gcp/vpc-network/outputs.tf | Exposes VPC/subnetwork outputs. |
| examples/gcp/vpc-network/versions.tf | Pins Terraform/provider constraints and configures the Google provider. |
| examples/gcp/vpc-network/README.md | Documents the GCP VPC network example usage and inputs/outputs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+25
to
+30
| resource "aws_subnet" "public" { | ||
| count = length(var.public_subnet_cidrs) | ||
| vpc_id = aws_vpc.this.id | ||
| cidr_block = var.public_subnet_cidrs[count.index] | ||
| availability_zone = data.aws_availability_zones.available.names[count.index] | ||
|
|
Comment on lines
+39
to
+44
| resource "aws_subnet" "private" { | ||
| count = length(var.private_subnet_cidrs) | ||
| vpc_id = aws_vpc.this.id | ||
| cidr_block = var.private_subnet_cidrs[count.index] | ||
| availability_zone = data.aws_availability_zones.available.names[count.index] | ||
|
|
Comment on lines
+21
to
+28
| Reference a module from an example or an external configuration using a relative path: | ||
|
|
||
| ```hcl | ||
| module "example" { | ||
| source = "../../modules/<module-name>" | ||
|
|
||
| # module inputs | ||
| } |
Comment on lines
+9
to
+26
| ## Usage | ||
|
|
||
| ```hcl | ||
| module "ec2" { | ||
| source = "../../examples/aws/ec2-instance" | ||
|
|
||
| region = "us-east-1" | ||
| instance_type = "t3.micro" | ||
| name = "my-instance" | ||
| } | ||
| ``` | ||
|
|
||
| Or use directly: | ||
|
|
||
| ```bash | ||
| terraform init | ||
| terraform apply -var="name=my-instance" | ||
| ``` |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bootstraps the repo with a consistent, scalable folder layout for hosting multiple Terraform examples across cloud providers.
Structure
Conventions
examples/<provider>/<resource>/main.tf,variables.tf,outputs.tf,versions.tf,README.mdversions.tf(AWS~> 5.0, AzureRM~> 3.0, Google~> 5.0).gitignorecovers.terraform/, state files, lock files, and*.tfvarsREADME.mdupdated with structure overview, per-example usage pattern, and contributing guideOriginal prompt