From 834d9efefbfa8bdcbfa620d35adf7062aa63ca7f Mon Sep 17 00:00:00 2001 From: devsjc Date: Mon, 13 Nov 2023 14:14:33 +0000 Subject: [PATCH] Add import block for s3 bucket --- terraform/modules/networking/main.tf | 4 ++-- terraform/modules/storage/s3-private/bucket.tf | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/terraform/modules/networking/main.tf b/terraform/modules/networking/main.tf index 0f7d6589..4d1c4d06 100644 --- a/terraform/modules/networking/main.tf +++ b/terraform/modules/networking/main.tf @@ -117,12 +117,12 @@ resource "aws_route" "private_nat_gateway" { // Add the routes to the route tables resource "aws_route_table_association" "public" { - count = length(aws_subnet.public_subnets) + count = var.num_public_subnets subnet_id = element(aws_subnet.public_subnets.*.id, count.index) route_table_id = aws_route_table.public.id } resource "aws_route_table_association" "private" { - count = length(aws_subnet.private_subnets) + count = var.num_private_subnets subnet_id = element(aws_subnet.private_subnets.*.id, count.index) route_table_id = aws_route_table.private.id } diff --git a/terraform/modules/storage/s3-private/bucket.tf b/terraform/modules/storage/s3-private/bucket.tf index cf684140..656742a2 100644 --- a/terraform/modules/storage/s3-private/bucket.tf +++ b/terraform/modules/storage/s3-private/bucket.tf @@ -11,6 +11,11 @@ resource "aws_s3_bucket" "bucket" { } } +import { + to = aws_s3_bucket.bucket + id = "${var.domain}-${var.service_name}-${var.environment}" +} + # Block all public access # https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_public_access_block resource "aws_s3_bucket_public_access_block" "access_block" {