Skip to content

Commit

Permalink
Use terraform vars to bump versions of software
Browse files Browse the repository at this point in the history
  • Loading branch information
hellais committed Feb 5, 2024
1 parent 2a46fd5 commit fa1831a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 16 deletions.
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
*.tfstate
*.tfstate.*

# Exclude all .tfvars files, which are likely to contain sensitive data
*.tfvars
*.tfvars.json

# Crash log files
crash.log
crash.*.log
Expand Down
10 changes: 3 additions & 7 deletions tf/environments/production/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ provider "aws" {

data "aws_availability_zones" "available" {}



resource "aws_vpc" "main" {
cidr_block = "10.0.0.0/16"
}
Expand Down Expand Up @@ -372,17 +370,15 @@ resource "aws_ecs_cluster" "main" {


locals {
container_image = "ooni/dataapi:latest"
container_name = "ooni_dataapi"
container_port = 80
container_name = "ooni_dataapi"
}

resource "aws_ecs_task_definition" "dataapi" {
family = "ooni-dataapi-production-td"
container_definitions = templatefile("${path.module}/templates/task_definition.json", {
image_url = local.container_image,
image_url = "ooni/dataapi:${var.ooni_service_config.dataapi_version}",
container_name = local.container_name,
container_port = local.container_port,
container_port = 80,
log_group_region = var.aws_region,
log_group_name = aws_cloudwatch_log_group.app.name
})
Expand Down
2 changes: 1 addition & 1 deletion tf/environments/production/templates/task_definition.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
}
}
}
]
]
5 changes: 5 additions & 0 deletions tf/environments/production/terraform.tfvars.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"ooni_service_config": {
"dataapi_version": "latest"
}
}
22 changes: 18 additions & 4 deletions tf/environments/production/variables.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
variable "datadog_api_key" {}
variable "aws_access_key_id" {}
variable "aws_secret_access_key" {}
variable "datadog_api_key" {
sensitive = true
}
variable "aws_access_key_id" {
sensitive = true
}
variable "aws_secret_access_key" {
sensitive = true
}

variable "aws_region" {
description = "The AWS region to create things in."
Expand All @@ -18,7 +24,15 @@ variable "key_name" {
default = "ooni-devops-prod"
}


variable "ooni_service_config" {
type = object({
dataapi_version = string
})
default = {
dataapi_version = "latest"
}
description = "configuration for ooni services"
}

variable "instance_type" {
default = "t2.micro"
Expand Down

0 comments on commit fa1831a

Please sign in to comment.