Giter VIP home page Giter VIP logo

Comments (2)

kevstewa avatar kevstewa commented on June 11, 2024 1

@brikis98 @adeomisor Launch configurations are no longer supported by AWS. You need to use a Launch Template. I've included an example below:

resource "aws_launch_template" "example" {
  image_id        = "ami-083eed19fc801d7a4"
  instance_type   = "t2.micro"
  vpc_security_group_ids = [aws_security_group.instance.id]

  user_data = base64encode(templatefile("user-data.sh", {
    server_port = var.server_port
    db_address = data.terraform_remote_state.db.outputs.address
    db_port = data.terraform_remote_state.db.outputs.port
  }))

  # Required when using a launch configuration with an auto scaling group.
  lifecycle {
    create_before_destroy = true
  }
}

resource "aws_autoscaling_group" "example" {
  launch_template {
    id = aws_launch_template.example.id
  }

  vpc_zone_identifier  = data.aws_subnets.default.ids

  target_group_arns = [aws_lb_target_group.asg.arn]
  health_check_type = "ELB"

  min_size = 2
  max_size = 10

  tag {
    key                 = "Name"
    value               = "${var.cluster_name}-asg"
    propagate_at_launch = true
  }
}

from terraform-up-and-running-code.

brikis98 avatar brikis98 commented on June 11, 2024

I am having some errors with the code from Chapter 3 when we split the code to folders. I had written the code on chapter 3 and it worked well till I got to the "Isolation via File Layout". I was using us-east-1 region. I deleted app resources from the us-east-1, including s3 buckets and other resources

Did you run terragrunt destroy?

After splitting the code into different folders, for the webserver-cluster, I changed the region to us-east-2. I ran terraform init and it was successful.

Terraform plan also worked well. When I ran terraform apply, it failed at the launch configuration with this error.:

aws_launch_configuration: "couldn't find `resource"

I discovered that it is pulling data from my us-east-1. I changed my .aws credentials to use us-east-2 as my default region but still getting the same issue.

If you didn't run destroy, then you still have state pointing at us-east-1. Switch your code back to us-east-1, run destroy, then finally switch to us-east-2.

But the global/S3 runs smoothly.

I created new folders and wrote a new code there and I am now getting this error:

**Initializing the backend...

Successfully configured the backend "s3"! Terraform will automatically use this backend unless the backend configuration changes. Error refreshing state: state data in S3 does not have the expected content.

This may be caused by unusually long delays in S3 processing a previous state update. Please wait for a minute or two and try again. If this problem persists, and neither S3 nor DynamoDB are experiencing an outage, you may need to manually verify the remote state and update the Digest value stored in the DynamoDB table to the following value:**

``

S3 buckets live in a specific region too. Did you switch the region in your code to us-east-2, but not actually re-create the bucket in that region?

from terraform-up-and-running-code.

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.