Skip to content

Commit

Permalink
Merge pull request #8 from danbarr/update-202306
Browse files Browse the repository at this point in the history
Update dependencies and defaults
  • Loading branch information
danbarr authored Jun 28, 2023
2 parents 0e170d2 + c9473cf commit dfa8d5b
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 126 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Local .terraform directories
**/.terraform/*

# Provider lock file (not wanted for demos)
.terraform.lock.hcl

# .tfstate files
*.tfstate
*.tfstate.*
Expand Down
105 changes: 0 additions & 105 deletions .terraform.lock.hcl

This file was deleted.

20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,28 @@

Provisions a simple nginx webserver with sample HashiCafe website in AWS EC2, using a base AMI registered in [HCP Packer](https://cloud.hashicorp.com/products/packer).

Default Packer bucket name matches the Ubuntu 20.04 Nginx image built with my [Packer example](https://github.com/danbarr/hcp-packer-ubuntu20).
Default Packer bucket name matches the Ubuntu 22.04 Nginx image built with my [Packer example](https://github.com/danbarr/hcp-packer-ubuntu22).

<!-- BEGIN_TF_DOCS -->
## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | ~> 4.0 |
| <a name="requirement_hcp"></a> [hcp](#requirement\_hcp) | ~> 0.46.0 |
| <a name="requirement_null"></a> [null](#requirement\_null) | ~> 3.1 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.2 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | ~> 5.0 |
| <a name="requirement_hcp"></a> [hcp](#requirement\_hcp) | ~> 0.62 |
| <a name="requirement_null"></a> [null](#requirement\_null) | ~> 3.2 |
| <a name="requirement_random"></a> [random](#requirement\_random) | ~> 3.4 |
| <a name="requirement_tls"></a> [tls](#requirement\_tls) | ~> 4.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | 4.54.0 |
| <a name="provider_hcp"></a> [hcp](#provider\_hcp) | 0.46.0 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.5.0 |
| <a name="provider_hcp"></a> [hcp](#provider\_hcp) | 0.62.0 |
| <a name="provider_null"></a> [null](#provider\_null) | 3.2.1 |
| <a name="provider_random"></a> [random](#provider\_random) | 3.4.3 |
| <a name="provider_random"></a> [random](#provider\_random) | 3.5.1 |
| <a name="provider_tls"></a> [tls](#provider\_tls) | 4.0.4 |

## Modules
Expand All @@ -41,6 +42,7 @@ No modules.
| [aws_route_table.hashicafe](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route_table) | resource |
| [aws_route_table_association.hashicafe](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route_table_association) | resource |
| [aws_security_group.hashicafe](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group) | resource |
| [aws_security_group_rule.ingress](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource |
| [aws_subnet.hashicafe](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/subnet) | resource |
| [aws_vpc.hashicafe](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc) | resource |
| [null_resource.configure-web-app](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |
Expand All @@ -54,10 +56,12 @@ No modules.
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_address_space"></a> [address\_space](#input\_address\_space) | The address space that is used by the virtual network. You can supply more than one address space. Changing this forces a new resource to be created. | `string` | `"10.0.0.0/16"` | no |
| <a name="input_department"></a> [department](#input\_department) | Value for the department tag. | `string` | `"WebDev"` | no |
| <a name="input_env"></a> [env](#input\_env) | Value for the environment tag. | `string` | n/a | yes |
| <a name="input_hashi_products"></a> [hashi\_products](#input\_hashi\_products) | n/a | <pre>list(object({<br> name = string<br> color = string<br> image_file = string<br> }))</pre> | <pre>[<br> {<br> "color": "#dc477d",<br> "image_file": "hashicafe_art_consul.png",<br> "name": "Consul"<br> },<br> {<br> "color": "#ffffff",<br> "image_file": "hashicafe_art_hcp.png",<br> "name": "HCP"<br> },<br> {<br> "color": "#60dea9",<br> "image_file": "hashicafe_art_nomad.png",<br> "name": "Nomad"<br> },<br> {<br> "color": "#63d0ff",<br> "image_file": "hashicafe_art_packer.png",<br> "name": "Packer"<br> },<br> {<br> "color": "#844fba",<br> "image_file": "hashicafe_art_terraform.png",<br> "name": "Terraform"<br> },<br> {<br> "color": "#2e71e5",<br> "image_file": "hashicafe_art_vagrant.png",<br> "name": "Vagrant"<br> },<br> {<br> "color": "#ffec6e",<br> "image_file": "hashicafe_art_vault.png",<br> "name": "Vault"<br> }<br>]</pre> | no |
| <a name="input_instance_type"></a> [instance\_type](#input\_instance\_type) | Specifies the AWS instance type. | `string` | `"t3.micro"` | no |
| <a name="input_packer_bucket"></a> [packer\_bucket](#input\_packer\_bucket) | HCP Packer bucket name containing the source image. | `string` | `"ubuntu20-nginx"` | no |
| <a name="input_owner"></a> [owner](#input\_owner) | Value for the owner tag. | `string` | `"web.developer"` | no |
| <a name="input_packer_bucket"></a> [packer\_bucket](#input\_packer\_bucket) | HCP Packer bucket name containing the source image. | `string` | `"ubuntu22-nginx"` | no |
| <a name="input_packer_channel"></a> [packer\_channel](#input\_packer\_channel) | HCP Packer image channel. | `string` | `"production"` | no |
| <a name="input_prefix"></a> [prefix](#input\_prefix) | This prefix will be included in the name of most resources. | `string` | n/a | yes |
| <a name="input_region"></a> [region](#input\_region) | The region where the resources are created. | `string` | `"us-east-2"` | no |
Expand Down
16 changes: 9 additions & 7 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
terraform {
required_version = ">= 1.2"

required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.0"
version = "~> 5.0"
}
hcp = {
source = "hashicorp/hcp"
version = "~> 0.46.0"
version = "~> 0.62"
}
null = {
source = "hashicorp/null"
version = "~> 3.1"
version = "~> 3.2"
}
random = {
source = "hashicorp/random"
Expand All @@ -29,7 +31,8 @@ provider "aws" {
default_tags {
tags = {
environment = var.env
department = "TPMM"
department = var.department
owner = var.owner
application = "HashiCafe website"
}
}
Expand Down Expand Up @@ -155,7 +158,7 @@ resource "aws_instance" "hashicafe" {

postcondition {
condition = self.ami == data.hcp_packer_image.ubuntu-webserver.cloud_image_id
error_message = "A newer source AMI is available in the HCP Packer channel, please re-deploy."
error_message = "A new source AMI is available in the HCP Packer channel, please re-deploy."
}

postcondition {
Expand All @@ -166,8 +169,7 @@ resource "aws_instance" "hashicafe" {
}

resource "aws_eip" "hashicafe" {
instance = aws_instance.hashicafe.id
vpc = true
domain = "vpc"
}

resource "aws_eip_association" "hashicafe" {
Expand Down
24 changes: 18 additions & 6 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ variable "env" {
description = "Value for the environment tag."
}

variable "packer_bucket" {
variable "department" {
description = "Value for the department tag."
type = string
description = "HCP Packer bucket name containing the source image."
default = "ubuntu20-nginx"
default = "WebDev"
}

variable "packer_channel" {
variable "owner" {
description = "Value for the owner tag."
type = string
description = "HCP Packer image channel."
default = "production"
default = "web.developer"
}

variable "address_space" {
Expand All @@ -44,6 +44,18 @@ variable "instance_type" {
default = "t3.micro"
}

variable "packer_bucket" {
type = string
description = "HCP Packer bucket name containing the source image."
default = "ubuntu22-nginx"
}

variable "packer_channel" {
type = string
description = "HCP Packer image channel."
default = "production"
}

variable "hashi_products" {
type = list(object({
name = string
Expand Down

0 comments on commit dfa8d5b

Please sign in to comment.