GithubHelp home page GithubHelp logo

traveloka / terraform-aws-autoscaling Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 96 KB

A terraform module which provisions an auto scaling group along with its launch template

License: Apache License 2.0

HCL 100.00%
hcl terraform terraform-module

terraform-aws-autoscaling's People

Contributors

aashari avatar andysaputra avatar aoktox avatar circleous avatar clavinjune avatar fadhilah-sukmojatmiko avatar febryantonius avatar franzramadhan avatar isen-ng avatar michaelhansel avatar rafikurnia avatar randiagi avatar rizkimhd avatar rkalgasi-tvlk avatar salvianreynaldi avatar udit-tvlk avatar yecklilien avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

terraform-aws-autoscaling's Issues

Add Time Sleep Before Destroy Old ASG

Community Note

  • Please vote on this issue by adding a ๐Ÿ‘ reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you have submitted a pull request addressing the same issue, please leave a comment!

Description

using slow_start parameter on aws alb terraform produce huge traffic degradation on asg, since our green environment hasn't yet to be ready for serving actual traffic, whereas blue environment has been terminated. Means, all the traffic will goes to canary cluster (in which 1 instance only)

New or Affected Resource(s)

Affected :

  • aws_autoscaling_group

New :

  • time_sleep

Potential Terraform Configuration Changes

resource "time_sleep" "wait_before_destroy" {
  destroy_duration = var.asg_time_sleep_before_destroy

  triggers = {
    asg_id = aws_autoscaling_group.main.id
  }

  lifecycle {
    create_before_destroy = true
  }
}

References

  • #0000

Terraform 0.12: allow setting aws_launch_template.credit_specification.cpu_credits

Community Note

  • Please vote on this issue by adding a ๐Ÿ‘ reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you have submitted a pull request addressing the same issue, please leave a comment!

Description

New or Affected Resource(s)

  • aws_launch_template

Potential Terraform Configuration Changes

provider "aws" {
  region = "ap-southeast-1"
}

module "asg" {
  source = "../.."

  service_name   = "fprbe"
  environment    = "production"
  product_domain = "fpr"
  description    = "Instances of fprbe-app"
  application    = "java-8"

  security_groups  = []
  instance_profile = "myinstance-profile"

  cpu_credits = "standard"

  image_owners = ["123456789012"]

  image_filters = [
    # See https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-images.html for complete filter options
    {
      name   = "name"
      values = ["traveloka-fprbe-app-*"]
    },
    # If you want to directly specify the image ID
    {
      name   = "image-id"
      values = ["ami-91920591023019"]
    },
  ]

  launch_template_overrides = [
    {
      "instance_type" = "m5.large"
    },
    {
      "instance_type" = "m4.large"
    },
  ]

  user_data = "echo starting fprbe"
  key_name  = ""

  asg_vpc_zone_identifier  = ["subnet-a2b50c9d", "subnet-718c9efe"]
  asg_lb_target_group_arns = []

  asg_wait_for_capacity_timeout = "1m"
}

References

Terraform Apply Error caused by Invalid launch template

Community Note

  • Please vote on this issue by adding a ๐Ÿ‘ reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment!

Summary

Error: Error creating AutoScaling Group: InvalidQueryParameter: Invalid launch template: When a network interface is provided, the security groups must be a part of it.
	status code: 400, request id: 229df5f1-621b-4c53-af50-e27106d772e2
  on .terraform/modules/asg/main.tf line 100, in resource "aws_autoscaling_group" "main":
 100: resource "aws_autoscaling_group" "main" {

Similiar Issue: hashicorp/terraform-provider-aws#4570
Aws Docs: https://docs.aws.amazon.com/autoscaling/ec2/userguide/create-launch-template.html

Module Version

v0.3.1

Terraform Version and Terraform AWS Provider Version

Terraform v0.12.26
+ provider.aws v2.68

Affected Resource(s)

  • aws_autoscaling_group

Terraform Configuration Files

same as examples/simple

Expected Behavior

terraform apply successfuly

Actual Behavior

terraform apply return below error

Error: Error creating AutoScaling Group: InvalidQueryParameter: Invalid launch template: When a network interface is provided, the security groups must be a part of it.
	status code: 400, request id: 229df5f1-621b-4c53-af50-e27106d772e2
  on .terraform/modules/asg/main.tf line 100, in resource "aws_autoscaling_group" "main":
 100: resource "aws_autoscaling_group" "main" {

Screnshots

Steps to Reproduce

  1. terraform apply

Important Factoids

References

  • #0000

Terraform 0.12: simple example init fails

Community Note

  • Please vote on this issue by adding a ๐Ÿ‘ reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment!

Summary

Module Version

Terraform Version and Terraform AWS Provider Version

Terraform v0.12.6
+ provider.aws v2.22.0

Affected Resource(s)

  • null_resource

Terraform Configuration Files

provider "aws" {
  region = "ap-southeast-1"
}

module "asg" {
  source = "../.."

  service_name   = "fprbe"
  environment    = "production"
  product_domain = "fpr"
  description    = "Instances of fprbe-app"
  application    = "java-8"

  security_groups  = []
  instance_profile = "myinstance-profile"

  image_owners = ["123456789012"]

  image_filters = [
    # See https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-images.html for complete filter options
    {
      name   = "name"
      values = ["traveloka-fprbe-app-*"]
    },
    # If you want to directly specify the image ID
    {
      name   = "image-id"
      values = ["ami-91920591023019"]
    },
  ]

  instance_type = "m5.large"
  user_data     = "echo starting fprbe"
  key_name      = ""

  asg_vpc_zone_identifier  = ["subnet-a2b50c9d", "subnet-718c9efe"]
  asg_lb_target_group_arns = []

  asg_wait_for_capacity_timeout = "1m"
}

Expected Behavior

Terraform has been successfully initialized!

Actual Behavior

There are some problems with the configuration, described below.

The Terraform configuration must be valid before initialization so that
Terraform can determine which modules and providers need to be installed.

Error: Invalid argument name

  on .terraform/modules/asg.asg_name/main.tf line 32, in resource "null_resource" "unsupported_resource_type":
  32:   "\n\nCurrently supported resource types: \n* ${join("\n* ", keys(local.max_character_length))}" = true

Argument names must not be quoted.


Error: Invalid argument name

  on .terraform/modules/asg.launch_template_name/main.tf line 32, in resource "null_resource" "unsupported_resource_type":
  32:   "\n\nCurrently supported resource types: \n* ${join("\n* ", keys(local.max_character_length))}" = true

Screnshots

Steps to Reproduce

  1. cd example/simple/
  2. terraform init

Important Factoids

References

The issue fixed in traveloka/terraform-aws-resource-naming@d6f091a (v0.17.0)

Unable to query AMI in self account (without explicit launch permission)

Community Note

  • Please vote on this issue by adding a ๐Ÿ‘ reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment!

Summary

When i used this module to lookup AMI in same account, it thrown this error

Error: Error refreshing state: 1 error occurred:
        * module.asg.data.aws_ami.latest_service_image: 1 error occurred:
        * module.asg.data.aws_ami.latest_service_image: data.aws_ami.latest_service_image: Your query returned no results. Please change your search criteria and try again.

Module Version

Terraform Version and Terraform AWS Provider Version

Terraform v0.11.14
+ provider.aws v2.22.0
+ provider.null v2.1.2
+ provider.random v2.1.2
+ provider.template v2.1.2

Affected Resource(s)

  • data.aws_ami.latest_service_image

Terraform Configuration Files

  image_owners  = ["${data.aws_caller_identity.current.account_id}"]
  image_filters = [
    {
      name   = "image-id"
      values = ["${var.ami_id}"]
    },
  ]

Expected Behavior

query returned an AMI ID.

Actual Behavior

query returned no results.

Screnshots

image

Steps to Reproduce

  1. terraform plan

Important Factoids

References

  • #0000

Add toggle for public_ip_association

Community Note

  • Please vote on this issue by adding a ๐Ÿ‘ reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you have submitted a pull request addressing the same issue, please leave a comment!

Description

New or Affected Resource(s)

  • resource "aws_launch_template" "main" {}

Potential Terraform Configuration Changes

# Copy-paste your Terraform configurations here.
# For large Terraform configs, please use a service like Google Drive and share a link to the ZIP file.

network_interfaces {
    associate_public_ip_address = "${var.associate_public_ip}"
}

variable "associate_public_ip" {
  description = "Whether to associate public IP to the instance"
  default     = "false"
}

References

Add additional_tag to ebs volume

Community Note

  • Please vote on this issue by adding a ๐Ÿ‘ reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you have submitted a pull request addressing the same issue, please leave a comment!

Description

Current terraform code (release/v0.2.x) doesn't has additional_tags, it's only has asg_tags which is only can tag ASG and EC2 resources. With asg_tags we can't add more custom tags for ebs volume.

I need an additional_tags to add Team tag to ebs volume resources from this module, so I will have a better cost attribution for volume across sub product domain in fpr. LaunchTemplate also will get benefit from additional_tags.

New or Affected Resource(s)

  • aws_launch_template.main

Potential Terraform Configuration Changes

  tags = "${merge(var.additional_tags, map(
          "Name", module.launch_template_name.name,
          "Service", var.service_name,
          "ProductDomain", var.product_domain,
          "Environment", var.environment,
          "ManagedBy", "terraform",
           ))}"

  tag_specifications = [
    {
      resource_type = "instance"

      tags = "${merge(var.additional_tags, map(
             	"Name", "${var.service_name}-${var.cluster_role}",
              "Service", var.service_name,
              "Cluster", "${var.service_name}-${var.cluster_role}",
              "ProductDomain", var.product_domain,
              "Application", var.application,
              "Environment", var.environment,
              "Description", var.description,
              "ManagedBy", "terraform"
              ))}"
    },
    {
      resource_type = "volume"

      tags = "${merge(var.additional_tags, map(
              "Service", var.service_name,
              "ProductDomain", var.product_domain,
              "Environment", var.environment,
              "ManagedBy", "terraform"
              ))}"
    },
  ]

Cannot Delete Security Group Attached to the Launch Template

Community Note

  • Please vote on this issue by adding a ๐Ÿ‘ reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment!

Summary

When adding capability for associate public IP (#34), we use network_interfaces block in the aws_launch_template. This block has default value false for delete_on_termination. It causes the ENI isn't deleted when we destroy the launch template and makes the security group attached to it can't be deleted.

Module Version

v0.3.2

Terraform Version and Terraform AWS Provider Version

Terraform v0.12.29
+ provider.aws v2.68.0

Affected Resource(s)

  • aws_launch_template

Terraform Configuration Files

resource "aws_launch_template" "main" {
  name = module.launch_template_name.name

  image_id      = data.aws_ami.latest_service_image.id
  instance_type = var.use_mixed_instances_policy == true ? null : var.launch_template_overrides[0].instance_type
  iam_instance_profile {
    name = var.instance_profile_name
  }

  credit_specification {
    cpu_credits = var.cpu_credits
  }

  key_name               = var.key_name
  user_data              = base64encode(var.user_data)

  network_interfaces {
    associate_public_ip_address = var.associate_public_ip
    security_groups             = var.security_groups
    delete_on_termination       = var.delete_network_interface_on_termination
  }

  monitoring {
    enabled = var.monitoring
  }

  ebs_optimized = var.ebs_optimized

  block_device_mappings {
    device_name = "/dev/sda1"

    ebs {
      volume_size           = var.volume_size
      volume_type           = var.volume_type
      delete_on_termination = var.delete_on_termination
      encrypted             = var.ebs_encryption
    }
  }

  tags = {
    Name          = module.launch_template_name.name
    Service       = var.service_name
    ProductDomain = var.product_domain
    Environment   = var.environment
    ManagedBy     = "terraform"
  }

  tag_specifications {
    resource_type = "instance"

    tags = {
      Name          = "${var.service_name}-${var.cluster_role}"
      Service       = var.service_name
      Cluster       = "${var.service_name}-${var.cluster_role}"
      ProductDomain = var.product_domain
      Application   = var.application
      Environment   = var.environment
      Description   = var.description
      ManagedBy     = "terraform"
    }
  }
  tag_specifications {
    resource_type = "volume"

    tags = {
      Service       = var.service_name
      ProductDomain = var.product_domain
      Environment   = var.environment
      ManagedBy     = "terraform"
    }
  }
}

Expected Behavior

When we destroy the cluster, we can destroy the security group attached to it

Actual Behavior

We can't destroy the security group because it's still attached to the ENI

Screnshots

Steps to Reproduce

  1. terraform apply
  2. terraform destroy

Important Factoids

References

Add asg desired capacity

Community Note

  • Please vote on this issue by adding a ๐Ÿ‘ reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you have submitted a pull request addressing the same issue, please leave a comment!

Description

Current version did not have support for asg desired capacity that is supported on 0.2.8. We need this since on release normally we need additional instances before gradually move to min baseline

New or Affected Resource(s)

  • aws_autoscaling_group

Potential Terraform Configuration Changes

desired_capacity          = var.asg_desired_capacity

References

  • #0000

Apply failed at 1st attemp due to diffs didn't match during apply

Community Note

  • Please vote on this issue by adding a ๐Ÿ‘ reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment!

Summary

I got this error when applying this module. But when i re-apply the code, it create resources successfully

module.aws-autoscaling_app.aws_autoscaling_group.main: aws_autoscaling_group.main: diffs didn't match during apply. This is a bug with Terraform and should be reported as a GitHub Issue.

Please include the following information in your report:

Terraform Version: 0.11.14
Resource ID: aws_autoscaling_group.main
Mismatch reason: extra attributes: tags.126663611.key, tags.126663611.%, tags.126663611.propagate_at_launch, tags.126663611.value

I think this one caused by the tag "Name" that lookup from another module as its value.

{
key = "Name"
value = "${module.asg_name.name}"
propagate_at_launch = false
},

Module Version

v0.2.3

Terraform Version and Terraform AWS Provider Version

$ terraform -v
Terraform v0.11.14
+ provider.aws v2.70.0
+ provider.null v1.0.0
+ provider.random v1.2.0
+ provider.template v2.1.2

Affected Resource(s)

  • aws_autoscaling_group.main

Terraform Configuration Files

module "aws-autoscaling_app" {
  source  = "traveloka/autoscaling/aws"
  version = "0.2.3"

  service_name   = "${local.service_name}"
  cluster_role   = "${local.service_role}"
  environment    = "${var.environment}"
  application    = "${var.application}"
  product_domain = "${local.product_domain}"
  description    = "${local.service_description}"

  asg_vpc_zone_identifier = [
    "${data.aws_subnet_ids.subnet_app_ids.ids}",
  ]

  asg_lb_target_group_arns = [
    "${module.alb-single-listener_lbint.tg_arn}",
  ]

  asg_min_capacity              = "${var.asg_min_capacity}"
  asg_max_capacity              = "${var.asg_max_capacity}"
  asg_health_check_type         = "${var.asg_health_check_type}"
  asg_health_check_grace_period = "${var.asg_health_check_grace_period}"
  asg_default_cooldown          = "${var.asg_default_cooldown}"
  asg_wait_for_capacity_timeout = "${var.asg_wait_for_capacity_timeout}"

  security_groups = [
    "${aws_security_group.payepg-app.id}",
    "${var.asg_additional_security_groups}",
  ]

  instance_profile_name        = "${module.aws-iam-role_app.instance_profile_name}"
  user_data                    = "${var.asg_user_data}"
  image_owners                 = "${var.asg_image_owner_ids}"
  mixed_instances_distribution = "${var.asg_mixed_instances_distribution}"
  image_filters                = "${local.ami_search_filter}"
  launch_template_overrides    = "${var.asg_launch_template_override}"

  asg_tags = [
    {
      key                 = "AmiId"
      value               = "${var.asg_ami_id}"
      propagate_at_launch = true
    },
    {
      key                 = "ServiceVersion"
      value               = "${local.app_service_version}"
      propagate_at_launch = true
    },
  ]
}

Expected Behavior

Resources created at first attempt.

Actual Behavior

Got error at first attemp, and need to re-execute terraform apply to provision the resources.

Screnshots

image

Steps to Reproduce

  1. terraform apply => error
  2. terraform apply => success

Important Factoids

At first attempt, the plan output look like this (only for ASG tags)

tags.#:                                                                                          "7"
tags.0.%:                                                                                        <computed>
tags.1141493681.%:                                                                               "3"
tags.1141493681.key:                                                                             "Environment"
tags.1141493681.propagate_at_launch:                                                             "0"
tags.1141493681.value:                                                                           "staging"
tags.1549330624.%:                                                                               "3"
tags.1549330624.key:                                                                             "ManagedBy"
tags.1549330624.propagate_at_launch:                                                             "0"
tags.1549330624.value:                                                                           "terraform"
tags.1627912306.%:                                                                               "3"
tags.1627912306.key:                                                                             "AmiId"
tags.1627912306.propagate_at_launch:                                                             "1"
tags.1627912306.value:                                                                           "ami-02959f2ed559ac605"
tags.2091551781.%:                                                                               "3"
tags.2091551781.key:                                                                             "Service"
tags.2091551781.propagate_at_launch:                                                             "0"
tags.2091551781.value:                                                                           "payepg"
tags.2209837006.%:                                                                               "3"
tags.2209837006.key:                                                                             "ProductDomain"
tags.2209837006.propagate_at_launch:                                                             "0"
tags.2209837006.value:                                                                           "pay"
tags.2664787174.%:                                                                               "3"
tags.2664787174.key:                                                                             "Description"
tags.2664787174.propagate_at_launch:                                                             "0"
tags.2664787174.value:                                                                           "ASG of the payepg-app cluster"

I try to apply naming module first

terraform apply --target=module.aws-autoscaling_app.module.asg_name.random_id.this

After naming module created, the plan output looks different

tags.#:                                     "7"
tags.1141493681.%:                          "3"
tags.1141493681.key:                        "Environment"
tags.1141493681.propagate_at_launch:        "0"
tags.1141493681.value:                      "staging"
tags.1549330624.%:                          "3"
tags.1549330624.key:                        "ManagedBy"
tags.1549330624.propagate_at_launch:        "0"
tags.1549330624.value:                      "terraform"
tags.1627912306.%:                          "3"
tags.1627912306.key:                        "AmiId"
tags.1627912306.propagate_at_launch:        "1"
tags.1627912306.value:                      "ami-02959f2ed559ac605"
tags.2091551781.%:                          "3"
tags.2091551781.key:                        "Service"
tags.2091551781.propagate_at_launch:        "0"
tags.2091551781.value:                      "payepg"
tags.2209837006.%:                          "3"
tags.2209837006.key:                        "ProductDomain"
tags.2209837006.propagate_at_launch:        "0"
tags.2209837006.value:                      "pay"
tags.2625938796.%:                          "3"
tags.2625938796.key:                        "Name"                                ==> added after module naming created
tags.2625938796.propagate_at_launch:        "0"                                   ==> added after module naming created
tags.2625938796.value:                      "payepg-app-527ccb7255b9e158"         ==> added after module naming created
tags.2664787174.%:                          "3"
tags.2664787174.key:                        "Description"
tags.2664787174.propagate_at_launch:        "0"
tags.2664787174.value:                      "ASG of the payepg-app cluster"

References

Update README.md

Community Note

  • Please vote on this issue by adding a ๐Ÿ‘ reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you have submitted a pull request addressing the same issue, please leave a comment!

Description

In order to increase collaboration and contribution on the development of this module, it is a good idea to start with enhancing the README file. We do have a template repository which contains several files that will become a standard: https://github.com/traveloka/terraform-aws-modules-template

On that repository you will find a README file that can be used as an example. What points should be written on the README.

The example README was created by @Rukaan and reviewed by @rafikurnia, @sumodirjo, and also other @traveloka/site-infra members. See traveloka/terraform-aws-modules-template#9 for more information.

References

AMI Based on the Amazon Linux 2 failed to boot

Community Note

  • Please vote on this issue by adding a ๐Ÿ‘ reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment!

Summary

AMI That is being created using the Amazon Linux 2 as a base Image failed to boot.

Module Version

0.3.8

Terraform Version and Terraform AWS Provider Version

Terraform v1.0.10 linux_amd64
+ provider.aws v3.64.2 linux_amd64

Affected Resource(s)

  • aws_XXXXX

Terraform Configuration Files

# Copy-paste your Terraform configurations here.
# For large Terraform configs, please use a service like Google Drive and share a link to the ZIP file.

Expected Behavior

Actual Behavior

Screnshots

Steps to Reproduce

  1. terraform apply
  2. <any_command_you_executed>

Important Factoids

References

  • #0000

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.