01a: update Linode Terraform for provider v2
- Update all modules to use Linode provider v2 (linode/linode ~> 2.0) - Replace deprecated cluster attribute with region in all modules - Update firewall to use ipv4/ipv6 instead of cidrs (TCP/UDP protocols) - Update LKE endpoint output to use api_endpoints[0] instead of deprecated hostname - Add OBJECT_STORAGE_CLUSTER variable for object storage configuration - Update Makefile with new variables and validate target - Add storage/outputs.tf for standardized object storage outputs - Update .env and .env.example with clean format (no inline comments) - Update all terraform.tfvars.example files for consistency
This commit is contained in:
1 parent
341cd05ac5
commit
494f38c1f3
17 files changed
+285
-203
No files matched your search
+15
-79
@@ -1,97 +1,33 @@
|
||||
# Object Storage module for HAPI
|
||||
# Creates buckets for uploads and Terraform state
|
||||
|
||||
terraform {
|
||||
required_providers {
|
||||
linode = {
|
||||
source = "linode/linode"
|
||||
version = "~> 2.0"
|
||||
}
|
||||
random = {
|
||||
source = "hashicorp/random"
|
||||
version = "~> 3.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resource "linode_object_storage_bucket" "uploads" {
|
||||
for_each = toset(["staging", "production"])
|
||||
|
||||
label = "hapi-uploads-${each.key}"
|
||||
cluster = var.linode_object_storage_cluster
|
||||
region = var.linode_object_storage_cluster
|
||||
access_key = var.object_storage_access_key
|
||||
secret_key = var.object_storage_secret_key
|
||||
depends_on = [linode_object_storage_cluster.this]
|
||||
}
|
||||
|
||||
resource "linode_object_storage_bucket" "state" {
|
||||
for_each = toset(["staging", "production"])
|
||||
|
||||
label = "hapi-terraform-state-${each.key}"
|
||||
cluster = var.linode_object_storage_cluster
|
||||
region = var.linode_object_storage_cluster
|
||||
access_key = var.object_storage_access_key
|
||||
secret_key = var.object_storage_secret_key
|
||||
depends_on = [linode_object_storage_cluster.this]
|
||||
}
|
||||
|
||||
resource "linode_object_storage_cluster" "this" {
|
||||
label = "hapi-object-storage"
|
||||
region = var.linode_region
|
||||
}
|
||||
|
||||
# Bucket configurations
|
||||
locals {
|
||||
bucket_config = {
|
||||
staging = {
|
||||
uploads = {
|
||||
label = "hapi-uploads-staging"
|
||||
policy = jsonencode({
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Principal": { "AWS": ["*"] },
|
||||
"Action": ["s3:GetObject", "s3:PutObject"],
|
||||
"Resource": ["arn:aws:s3:::hapi-uploads-staging/*"]
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
state = {
|
||||
label = "hapi-terraform-state-staging"
|
||||
}
|
||||
}
|
||||
production = {
|
||||
uploads = {
|
||||
label = "hapi-uploads-production"
|
||||
policy = jsonencode({
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Principal": { "AWS": ["*"] },
|
||||
"Action": ["s3:GetObject", "s3:PutObject"],
|
||||
"Resource": ["arn:aws:s3:::hapi-uploads-production/*"]
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
state = {
|
||||
label = "hapi-terraform-state-production"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
output "endpoint" {
|
||||
description = "Object Storage endpoint"
|
||||
value = "https://${var.linode_region}.linodeobjects.com"
|
||||
}
|
||||
|
||||
output "access_key" {
|
||||
description = "Object Storage access key"
|
||||
value = var.object_storage_access_key
|
||||
}
|
||||
|
||||
output "secret_key" {
|
||||
description = "Object Storage secret key"
|
||||
value = var.object_storage_secret_key
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
output "state_bucket_name" {
|
||||
description = "Name of the Terraform state bucket"
|
||||
value = "hapi-terraform-state-${var.environment}"
|
||||
}
|
||||
|
||||
output "uploads_bucket_name" {
|
||||
description = "Name of the uploads bucket"
|
||||
value = "hapi-uploads-${var.environment}"
|
||||
}
|
||||
Reference in new issue
Block a user