Skip to content

Commit

Permalink
Add initial variables, locals and provider
Browse files Browse the repository at this point in the history
* Adds the project name, infrastructure name and environment variables
  to be used to create a resource prefix
* Adds the aws region variable, to determine which region the resources
  will be created
* Adds default tags
* Adds the AWS provider
  • Loading branch information
Stretch96 committed Nov 7, 2023
1 parent bcde6c6 commit 85c5f28
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 3 deletions.
24 changes: 24 additions & 0 deletions .terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ This project creates and manages resources within an AWS account for infrastruct

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.6.2 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.6.3 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.24.0 |

## Providers

Expand All @@ -22,7 +23,12 @@ No resources.

## Inputs

No inputs.
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_aws_region"></a> [aws\_region](#input\_aws\_region) | AWS region in which to launch resources | `string` | n/a | yes |
| <a name="input_environment"></a> [environment](#input\_environment) | The environment name to be used as part of the resource prefix | `string` | n/a | yes |
| <a name="input_infrastructure_name"></a> [infrastructure\_name](#input\_infrastructure\_name) | The infrastructure name to be used as part of the resource prefix | `string` | n/a | yes |
| <a name="input_project_name"></a> [project\_name](#input\_project\_name) | Project name to be used as a prefix for all resources | `string` | n/a | yes |

## Outputs

Expand Down
11 changes: 11 additions & 0 deletions locals.tf
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
locals {
project_name = var.project_name
infrastructure_name = var.infrastructure_name
environment = var.environment
aws_region = var.aws_region
resource_prefix = "${var.project_name}-${var.infrastructure_name}-${var.environment}"

Check warning on line 6 in locals.tf

View workflow job for this annotation

GitHub Actions / tflint

local.resource_prefix is declared but not used

default_tags = {
Project = local.project_name,
Infrastructure = local.infrastructure_name,
Environment = local.environment,
}
}
7 changes: 7 additions & 0 deletions providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
provider "aws" {
region = local.aws_region

default_tags {
tags = local.default_tags
}
}
19 changes: 19 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
variable "project_name" {
description = "Project name to be used as a prefix for all resources"
type = string
}

variable "infrastructure_name" {
description = "The infrastructure name to be used as part of the resource prefix"
type = string
}

variable "environment" {
description = "The environment name to be used as part of the resource prefix"
type = string
}

variable "aws_region" {
description = "AWS region in which to launch resources"
type = string
}
6 changes: 5 additions & 1 deletion versions.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
terraform {
required_version = ">= 1.6.2"
required_version = ">= 1.6.3"
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.24.0"
}
}
}

0 comments on commit 85c5f28

Please sign in to comment.