:wave::skin-tone-4: Can anyone share a terraform s...
# ask-metaflow
c
👋🏽 Can anyone share a terraform script to setup a minimal infra on an existing (aws) vpc. I tried it myself with what seemed to me are the obvious changes. Alas! The metadata-service kept crashing complaining about “error connecting”. Its possible that bringing up a fresh vpc does not have such issues but thats not an option for me
1
v
hey Asif! Great to see you here meow wave
c
Hey Ville. Good to be here. Finally got things working and now basking in the goodness of metaflow 😄
h
Hey asif if you need something super minimal, here you go :
Copy code
# Random suffix for this deployment
resource "random_string" "suffix" {
  length  = 8
  special = false
  upper = false
}


locals {
  resource_prefix = "metaflow"
  resource_suffix = random_string.suffix.result
  subnet_ids = [for x,y in data.aws_subnet_ids.pre_created_public_subnet_ids.ids : y]
}
variable "with_public_ip" { # TODO : ADD PUBLIC IP PREFERENCE HERE
  default = true
}

variable "vpc_id" {} # TODO : ADD YOUR VPC ID HERE

data "aws_vpc" "pre_created_vpc" {
  id = var.vpc_id
}

data "aws_subnet_ids" "pre_created_public_subnet_ids" {
  vpc_id = var.vpc_id
  filter {
    name   = "map-public-ip-on-launch"
    values = ["true"]
  }
}

module "metaflow" {
  source = "outerbounds/metaflow/aws"
  version = "0.9.2"

  resource_prefix = local.resource_prefix
  resource_suffix = local.resource_suffix

  enable_step_functions = false
  subnet1_id            = local.subnet_ids[0]
  subnet2_id            = local.subnet_ids[1]
  vpc_cidr_blocks       = data.aws_vpc.pre_created_vpc.cidr_block_associations.*.cidr_block
  vpc_id                = var.vpc_id
  with_public_ip        = var.with_public_ip

  tags = {
      "managedBy" = "terraform"
  }
}

# The module will generate a Metaflow config in JSON format, write it to a file
resource "local_file" "metaflow_config" {
  content  = module.metaflow.metaflow_profile_json
  filename = "./metaflow_profile.json"
}
🙌 1
c
Thanks Valay. Most helpful. I ended up with something similar and had a minor issue. Maybe this would be of minor interest to you https://github.com/outerbounds/terraform-aws-metaflow/issues/53