Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow snapshot_id to be specified for additional_ebs_volumes #1431

Merged
merged 3 commits into from
Oct 7, 2021
Merged

feat: Allow snapshot_id to be specified for additional_ebs_volumes #1431

merged 3 commits into from
Oct 7, 2021

Conversation

omjadas
Copy link
Contributor

@omjadas omjadas commented Jun 8, 2021

PR o'clock

Description

Allow additional ebs volumes to be created from snapshots.

Checklist

@omjadas
Copy link
Contributor Author

omjadas commented Oct 3, 2021

@antonbabenko @daroga0002 would it be possible to get a review for this PR?

@daroga0002
Copy link
Contributor

@antonbabenko @daroga0002 would it be possible to get a review for this PR?

I will look into this, do you maybe have a example of module configuration which I can use for testing?

@omjadas
Copy link
Contributor Author

omjadas commented Oct 7, 2021

I will look into this, do you maybe have a example of module configuration which I can use for testing?

Sure thing, the following works to illustrate its use (we use a similar config in order to decrease pod start times on fresh nodes).

  1. Apply the following
  2. Create a snapshot from the /dev/xvdb volume on the instance that starts up
  3. Update snapshot_id with ID of created snapshot
  4. Apply
# main.tf

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 3.37"
    }
  }
  required_version = "~> 1.0"
}

provider "aws" {
  region = local.region
}

locals {
  region      = "us-west-2"
  k8s_version = "1.21"
}

data "aws_vpc" "default" {
  default = true
}

data "aws_subnet_ids" "default" {
  vpc_id = data.aws_vpc.default.id
}

module "eks" {
  source = "github.com/omjadas/terraform-aws-eks?ref=feat%2Fsnapshot_id"

  create_eks       = true
  cluster_name     = "test-cluster"
  cluster_version  = local.k8s_version
  vpc_id           = data.aws_vpc.default.id
  subnets          = data.aws_subnet_ids.default.ids
  manage_aws_auth  = false
  enable_irsa      = false
  write_kubeconfig = false

  worker_ami_name_filter = "bottlerocket-aws-k8s-${local.k8s_version}-x86_64-v*"

  worker_groups_launch_template = [
    {
      name                   = "nodes"
      asg_min_size           = 1
      asg_max_size           = 1
      asg_desired_capacity   = 1
      default_cooldown       = 60
      instance_type          = "t3a.medium"
      protect_from_scale_in  = false
      public_ip              = true
      userdata_template_file = "${path.module}/userdata.toml.tpl"
      root_encrypted         = true
      root_volume_type       = "gp3"
      additional_ebs_volumes = [
        {
          block_device_name = "/dev/xvdb"
          encrypted         = true
          volume_size       = 50
          volume_type       = "gp3"
          # snapshot_id       = "<<snapshot id here>>"
        }
      ]
    }
  ]
}
# userdata.toml.tpl

[settings.kubernetes]
api-server = "${endpoint}"
cluster-certificate ="${cluster_auth_base64}"
cluster-name = "${cluster_name}"

Copy link
Contributor

@daroga0002 daroga0002 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tested and is working nice so can be merged 🚀

@omjadas thank you for contribution

@antonbabenko this can be merged, I have 3 more PRs to test and then we can make consolidated release

@antonbabenko antonbabenko changed the title feat: allow snapshot_id to be specified for additional_ebs_volumes feat: Allow snapshot_id to be specified for additional_ebs_volumes Oct 7, 2021
@antonbabenko antonbabenko merged commit 8866569 into terraform-aws-modules:master Oct 7, 2021
lisfo4ka pushed a commit to lisfo4ka/terraform-aws-eks that referenced this pull request Oct 12, 2021
@github-actions
Copy link

I'm going to lock this pull request 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 related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants