Code Monkey home page Code Monkey logo

Comments (11)

bangpound avatar bangpound commented on July 27, 2024

To avoid this, use the literal ID for the VPC rather than a data source attribute.

from terraform-aws-atlantis.

antonbabenko avatar antonbabenko commented on July 27, 2024

Data sources should be fine also as long as they are not referring to values which are not known before the execution (eg, VPC should be created before it is discovered using data source).

Good that you found the solution!

from terraform-aws-atlantis.

smiller171 avatar smiller171 commented on July 27, 2024

@antonbabenko I'm seeing data sources failing even when the value is known before the execution

from terraform-aws-atlantis.

smiller171 avatar smiller171 commented on July 27, 2024
$ terraform console
> data.terraform_remote_state.core.vpc_id.test
vpc-0643f5b708f5fb8e1
$ terraform validate

Error: module.atlantis.module.vpc.aws_vpc_ipv4_cidr_block_association.this: 1 error(s) occurred:

* module.atlantis.module.vpc.aws_vpc_ipv4_cidr_block_association.this: element: element() may not be used with an empty list in:

${element(var.secondary_cidr_blocks, count.index)}



Error: module.atlantis.module.vpc.aws_eip.nat: 1 error(s) occurred:

* module.atlantis.module.vpc.aws_eip.nat: element: element() may not be used with an empty list in:

${merge(map("Name", format("%s-%s", var.name, element(var.azs, (var.single_nat_gateway ? 0 : count.index)))), var.tags, var.nat_eip_tags)}



Error: module.atlantis.module.vpc.aws_vpc.this: expected cidr_block to contain a valid CIDR, got:  with err: invalid CIDR address

from terraform-aws-atlantis.

sc250024 avatar sc250024 commented on July 27, 2024

Having the same issue

from terraform-aws-atlantis.

antonbabenko avatar antonbabenko commented on July 27, 2024

@smiller171 @sc250024 Could you please share your configs?

from terraform-aws-atlantis.

smiller171 avatar smiller171 commented on July 27, 2024

Yeah, I'll try to remember on Monday

from terraform-aws-atlantis.

albertogg avatar albertogg commented on July 27, 2024

Hi, I'm having the same issue. @bangpound solution works, but I wonder why is this race condition occurring.

My configuration:

module "atlantis" {
  source  = "terraform-aws-modules/atlantis/aws"
  version = "1.16.0"

  name = "${var.name}"

  # VPC
  vpc_id             = "${data.terraform_remote_state.us_west_network_vpc_main.vpc_id}"
  private_subnet_ids = ["${data.terraform_remote_state.us_west_network_vpc_main.private_subnets}"]
  public_subnet_ids  = ["${data.terraform_remote_state.us_west_network_vpc_main.public_subnets}"]

  # DNS
  route53_zone_name = "${data.terraform_remote_state.domain.name}"
  certificate_arn   = "${data.terraform_remote_state.domain.virginia_certificate_arn}"

  # CloudWatch
  cloudwatch_log_retention_in_days = 90

  # Atlantis GitLab
  atlantis_gitlab_hostname                      = "${var.gitlab_hostname}"
  atlantis_gitlab_user                          = "${var.gitlab_user}"
  atlantis_gitlab_user_token                    = "${var.gitlab_user_token}"
  atlantis_gitlab_user_token_ssm_parameter_name = "${local.ssm_base_path}/gitlab/atlantis/user/token"

  # Webhook secret
  webhook_ssm_parameter_name = "${local.ssm_base_path}/gitlab/atlantis/webhook/secret"

  # Allow users to configurate atlantis from their repos
  allow_repo_config = "true"

  # Required
  atlantis_repo_whitelist = "${var.repo_whitelist}"

  tags = "${local.common_tags}"
}

from terraform-aws-atlantis.

parkbeetech avatar parkbeetech commented on July 27, 2024

@antonbabenko Here are the files below. Note that the VPC module is the official one maintained at https://registry.terraform.io/modules/terraform-aws-modules/vpc/aws.

$ terraform version
Terraform v0.11.13
+ provider.aws v2.6.0
+ provider.null v2.1.1
+ provider.random v2.1.1
+ provider.template v2.1.1

main.tf

provider "aws" {
  region  = "${var.aws_region}"
  version = "~> 2.6"
}

provider "null" {
  version = "~> 2.1"
}

provider "random" {
  version = "~> 2.1"
}

provider "template" {
  version = "~> 2.1"
}

########
# Main #
########

module "atlantis" {
  atlantis_allowed_repo_names      = ["my-terraform-repo"]
  atlantis_github_user             = "myorggithubuser"
  atlantis_github_user_token       = "${var.atlantis_github_user_token}"
  atlantis_repo_whitelist          = ["github.com/myorg/my-terraform-repo"]
  atlantis_version                 = "v0.7.1"
  azs                              = "${data.aws_availability_zones.available.names}"
  cloudwatch_log_retention_in_days = 7
  create_route53_record            = true
  private_subnet_ids               = "${data.terraform_remote_state.vpc.private_subnets}"
  public_subnet_ids                = "${data.terraform_remote_state.vpc.public_subnets}"
  route53_zone_name                = "myorg.net"
  source                           = "terraform-aws-modules/atlantis/aws"
  version                          = "1.16.0"
  vpc_id                           = "${data.terraform_remote_state.vpc.vpc_id}"
}

data.tf

data "aws_availability_zones" "available" {}

data "terraform_remote_state" "vpc" {
  backend = "s3"

  config {
    bucket = "pb-euw1-prod-s3-terraform-state"
    key    = "aws/prod/${var.aws_region}/vpc/terraform.tfstate"
    region = "eu-west-1"
  }
}

vars.tf

variable "aws_region" {
  default = "eu-west-1"
  type    = "string"
}

variable "atlantis_github_user_token" {
  description = "GitHub token of the user that is running the Atlantis command"
  type        = "string"
}

from terraform-aws-atlantis.

smiller171 avatar smiller171 commented on July 27, 2024

I think there's an issue going on here specifically with terraform_remote_state

from terraform-aws-atlantis.

github-actions avatar github-actions commented on July 27, 2024

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

from terraform-aws-atlantis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.