Skip to content
This repository has been archived by the owner on Jan 30, 2021. It is now read-only.

Is this module deprecated ? #15

Open
iamaverrick opened this issue Apr 13, 2020 · 2 comments
Open

Is this module deprecated ? #15

iamaverrick opened this issue Apr 13, 2020 · 2 comments

Comments

@iamaverrick
Copy link

Hello we are trying to use this module as we still use KOPS and will like to create kops state backend using this module. we are currently using terraform

terraform -version
Terraform v0.12.24
+ provider.aws v2.57.0
+ provider.null v2.1.2
+ provider.template v2.1.2

and this is the error we are getting when we implement the module.

Error: Unsupported block type

  on .terraform/modules/kops-state-backend.domain/main.tf line 18, in data "template_file" "zone_name":
  18:   vars {

Blocks of type "vars" are not expected here. Did you mean to define argument
"vars"? If so, use the equals sign to assign it a value.


Error: Unsupported block type

  on .terraform/modules/kops-state-backend/terraform-aws-kops-state-backend-0.3.0/main.tf line 11, in data "template_file" "zone_name":
  11:   vars {

Blocks of type "vars" are not expected here. Did you mean to define argument
"vars"? If so, use the equals sign to assign it a value.

i think this module needs to be updated to terraform .12, also i see there is a higher version of 0.3.0 available but in the example it seems to be outdated

module "kops-state-backend" {
  source  = "cloudposse/kops-state-backend/aws"
  version = "0.1.7"
  # insert the 2 required variables here
} 

solution

module "kops-state-backend" {
  source  = "cloudposse/kops-state-backend/aws"
  version = "0.3.0"
  # insert the 2 required variables here
}

if this module is deprecated and is no longer receiving updates is there a similar module which we can use that will do the same?

@iamaverrick
Copy link
Author

provider "aws" {
  version = "~> 2.17"

  alias  = "s3"
  region = var.region
}

data "template_file" "zone_name" {
  template = replace(var.zone_name, "$$$$", "$")

  vars = {
    namespace        = var.namespace
    name             = var.cluster_name
    stage            = var.stage
    parent_zone_name = var.parent_zone_name
  }
}

locals {
  create_s3_bucket = true == var.create_bucket == "true"

  tags = merge(
    var.tags,
    {
      "Cluster" = data.template_file.zone_name.rendered
    },
  )

}

# Kops domain (e.g. `kops.domain.com`)
module "domain" {
  source           = "git::https://github.com/cloudposse/terraform-aws-route53-cluster-zone.git?ref=tags/0.4.0"
  namespace        = var.namespace
  name             = var.cluster_name
  stage            = var.stage
  delimiter        = var.delimiter
  attributes       = var.attributes
  zone_name        = var.zone_name
  parent_zone_id   = var.parent_zone_id
  parent_zone_name = var.parent_zone_name
  tags             = local.tags
  enabled          = var.domain_enabled
}

module "s3_label" {
  source     = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.16.0"
  namespace  = var.namespace
  name       = var.name
  stage      = var.stage
  delimiter  = var.delimiter
  attributes = var.attributes
  tags       = local.tags
}

data "aws_s3_bucket" "default" {
  provider = aws.s3

  count  = local.create_s3_bucket ? 0 : 1
  bucket = module.s3_label.id
}

resource "aws_s3_bucket" "default" {
  provider = aws.s3

  count         = local.create_s3_bucket ? 1 : 0
  bucket        = module.s3_label.id
  acl           = var.acl
  region        = var.region
  force_destroy = var.force_destroy

  versioning {
    enabled = true
  }

  server_side_encryption_configuration {
    rule {
      apply_server_side_encryption_by_default {
        sse_algorithm = "AES256"
      }
    }
  }

  tags = module.s3_label.tags
}

resource "aws_s3_bucket_public_access_block" "default" {
  provider = aws.s3

  count  = local.create_s3_bucket && var.block_public_access_enabled == "true" ? 1 : 0
  bucket = aws_s3_bucket.default[0].id

  block_public_acls       = true
  block_public_policy     = true
  ignore_public_acls      = true
  restrict_public_buckets = true
}

ive updated code to this but im getting this error now

Error: Failed getting S3 bucket: NotFound: Not Found
        status code: 404, request id: CDC40B82EFD19F33, host id: p1nGhHhd7TUOYjGU84ZpJ7de2rA0OhS390/PUwSIFEKwqA905OhWoSPAb2mKwI7KLpxVnDfq+Bo= Bucket: "bare.prod.blueamber"

  on ../modules/aws/kops-state-backend/main.tf line 56, in data "aws_s3_bucket" "default":
  56: data "aws_s3_bucket" "default" {

can anybody guide me please on how to resolve ?

@iamaverrick
Copy link
Author

Resolution for those who want to use this module and get stuck like how i was

provider "aws" {
  version = "2.57.0"

  alias  = "s3"
  region = var.region
}

data "template_file" "zone_name" {
  template = replace(var.zone_name, "$$$$", "$")

  vars = {
    namespace        = var.namespace
    name             = var.cluster_name
    stage            = var.stage
    parent_zone_name = var.parent_zone_name
  }
}

locals {
  create_s3_bucket = "${!(var.create_bucket == "false")}"

  tags = merge(
    var.tags,
    {
      "Cluster" = data.template_file.zone_name.rendered
    },
  )

}

# Kops domain (e.g. `kops.domain.com`)
module "domain" {
  source           = "git::https://github.com/cloudposse/terraform-aws-route53-cluster-zone.git?ref=tags/0.4.0"
  namespace        = var.namespace
  name             = var.cluster_name
  stage            = var.stage
  delimiter        = var.delimiter
  attributes       = var.attributes
  zone_name        = var.zone_name
  parent_zone_id   = var.parent_zone_id
  parent_zone_name = var.parent_zone_name
  tags             = local.tags
  enabled          = var.domain_enabled
}

module "s3_label" {
  source     = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.16.0"
  namespace  = var.namespace
  name       = var.name
  stage      = var.stage
  delimiter  = var.delimiter
  attributes = var.attributes
  tags       = local.tags
}

data "aws_s3_bucket" "default" {
  provider = aws.s3

  count  = local.create_s3_bucket ? 0 : 1
  bucket = module.s3_label.id
}

resource "aws_s3_bucket" "default" {
  provider = aws.s3

  count         = local.create_s3_bucket ? 1 : 0
  bucket        = module.s3_label.id
  acl           = var.acl
  region        = var.region
  force_destroy = var.force_destroy

  versioning {
    enabled = true
  }

  server_side_encryption_configuration {
    rule {
      apply_server_side_encryption_by_default {
        sse_algorithm = "AES256"
      }
    }
  }

  tags = module.s3_label.tags
}

resource "aws_s3_bucket_public_access_block" "default" {
  provider = aws.s3

  count  = local.create_s3_bucket && var.block_public_access_enabled == "true" ? 1 : 0
  bucket = aws_s3_bucket.default[0].id

  block_public_acls       = true
  block_public_policy     = true
  ignore_public_acls      = true
  restrict_public_buckets = true
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant