From 63af43cb74496f03e17711952fa3e9d0069ccb84 Mon Sep 17 00:00:00 2001 From: Rick Sherman Date: Fri, 19 Feb 2021 17:00:51 -0600 Subject: [PATCH] March 2021 Updates Updated for e-commerce repo changes Update included software Add support for specifying GCP network with Packer and Terraform --- datadog/.gitignore | 12 +++++++++++- datadog/setup/main.tf | 24 ++++++++++++++++-------- datadog/setup/packer/Makefile | 7 +++++-- datadog/setup/packer/bootstrap.sh | 8 ++++---- datadog/setup/packer/packer.json | 4 +++- 5 files changed, 39 insertions(+), 16 deletions(-) diff --git a/datadog/.gitignore b/datadog/.gitignore index d01ac64..d10a6b7 100644 --- a/datadog/.gitignore +++ b/datadog/.gitignore @@ -1,2 +1,12 @@ .terraform -*tfstate* \ No newline at end of file +*tfstate* + +# Exclude all .tfvars files, which are likely to contain sentitive data, such as +# password, private keys, and other secrets. These should not be part of version +# control as they are data points which are potentially sensitive and subject +# to change depending on the environment. +# +*.tfvars + +# Ignore lock files +.terraform.lock.hcl diff --git a/datadog/setup/main.tf b/datadog/setup/main.tf index b93c72b..b1f7b6e 100644 --- a/datadog/setup/main.tf +++ b/datadog/setup/main.tf @@ -2,7 +2,7 @@ terraform { required_providers { google = { source = "hashicorp/google" - version = "3.39.0" + version = "3.57.0" } } @@ -10,6 +10,7 @@ terraform { } provider "google" { + project = var.project zone = var.zone } @@ -18,12 +19,23 @@ variable "dd_api_key" { description = "Datadog Agent API key" } +variable "project" { + type = string + description = "GCP Project" +} + variable "zone" { type = string description = "GCP Zone to deploy" default = "us-east1-b" } +variable "network" { + type = string + description = "GCP VCP to deploy" + default = "default" +} + variable "enable_firewall_rule" { type = bool description = "Creates firewall rule to allow public traffic" @@ -36,14 +48,10 @@ variable "fix_frontend" { default = true } -data "google_compute_network" "default" { - name = "default" -} - resource "google_compute_firewall" "ecommerce" { count = var.enable_firewall_rule ? 1 : 0 name = "allow-ecommerce" - network = "default" + network = var.network allow { protocol = "tcp" @@ -73,7 +81,7 @@ resource "google_compute_instance" "ecommerce" { } network_interface { - network = "default" + network = var.network access_config { nat_ip = google_compute_address.ecommerce.address @@ -86,7 +94,7 @@ resource "google_compute_instance" "ecommerce" { } metadata_startup_script = <