#terraform - November 2019

November 2019
Sharanya
Sharanyaabout 7 years ago
Hey Guys, I have a Quick Question - if any one has every come across this "Is there any way we can make our S3 bucket Private and then Cloudfront provides - URL , Which can be viewed from this Private S3 Bucket" ?
jafow
jafowabout 7 years ago
👋 acm certs DNS validation with assume role
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)about 7 years ago
Interesting read on why terraform providers for Kubernetes and helm are less than ideal... see comment by pulumi developer. https://www.reddit.com/r/devops/comments/awy81c/managing_helm_releases_terraform_helmsman/?utm_source=share&utm_medium=ios_app&utm_name=iossmf
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)about 7 years ago
(It’s also a bit older post. Maybe something have been addressed in later releases of the providers and 0.12)
winter
winterabout 7 years ago
If I renamed a folder, terrafrom is creating a new resource from that folder. How do I fix this in the state?
Mateusz Kamiński
Mateusz Kamińskiabout 7 years ago
How do you use this folder in terraform? Module?
Mateusz Kamiński
Mateusz Kamińskiabout 7 years ago
If module then path should not matter as long as module name stays same
winter
winterabout 7 years ago
Actually this folder stores terragrunt file
Mateusz Kamiński
Mateusz Kamińskiabout 7 years ago
Oh, so it is terragrunt - i haven't used it - won't help
Chris Fowles
Chris Fowlesalmost 7 years ago
incase anyone else get's a requirement to convert TitleCaseText to kabab-case-text in terraform here you go:
lower(join("-", flatten(regexall("([A-Z][a-z]*)", "ThisIsTitleCaseStuff"))))
Chris Fowles
Chris Fowlesalmost 7 years ago
I don't think I'll ever need to do that again, but it felt a shame to waste
Bruce
Brucealmost 7 years ago
Has anyone seen any good resources for using terratest, examples etc and they have tied it in to a CI/CD pipeline?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
They all use terratest with ci/cd (#codefresh)
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
basically, every terraform 0.12 (HCL2) module we have has terratest
Bruce
Brucealmost 7 years ago
Thanks @Erik Osterman (Cloud Posse) 😁
C
Cloud Possealmost 7 years ago
:zoom: Join us for "Office Hours" every Wednesday 11:30AM (PST, GMT-7) via Zoom.

This is an opportunity to ask us questions on terraform and get to know others in the community on a more personal level. Next one is Nov 13, 2019 11:30AM.

👉️ Register for Webinar

:slack: #office-hours (our channel)
kskewes
kskewesalmost 7 years ago(edited)
hey everyone, couple questions about the EKS module. https://github.com/cloudposse/terraform-aws-eks-workers
1. The default 'use latest image' filter and data source doesn't seem to work for me. Using var.region value of "ap-southeast-2" results in 1.11 nodes with a 1.14 cluster (I set cluster version to 1.14). Any ideas?
This works: aws ssm get-parameter --name /aws/service/eks/optimized-ami/1.14/amazon-linux-2/recommended/image_id --region ap-southeast-2 --query "Parameter.Value" --output text
2. I think we will generally set AMI's and in doing so I see the launch template has updated but new version is not default and the nodes aren't rolling automatically (updated in place, dummy cluster). Is this expected behaviour? If I terraform destroy -resource=workerpool1 followed by an apply I get the newer node version.
3. Will PR custom configmap template once get cluster going.
4. Have egress from an alpine pod to 8.8.8.8:53 but don't seem to have DNS in cluster. Using multi-az subnets and tagging private (nodes), public (nlb/alb), shared, owned..
oscar
oscaralmost 7 years ago

data "aws_ssm_parameter" "eks_ami" {
  name = "/aws/service/eks/optimized-ami/${var.kubernetes_version}/amazon-linux-2/recommended/image_id"
}



module "eks_workers_1" {
  source = "git::<https://github.com/cloudposse/terraform-aws-eks-workers.git?ref=tags/0.10.0>"

  use_custom_image_id = true
  image_id            = data.aws_ssm_parameter.eks_ami.value
oscar
oscaralmost 7 years ago
try this
cabrinha
cabrinhaalmost 7 years ago
howdy all... I'm trying to use cidrsubnets() to take a /16 and chop it up into /24's for my subnets...
cabrinha
cabrinhaalmost 7 years ago
however, I think that I may need to hardcode the cidr blocks I want to use for my subnets
cabrinha
cabrinhaalmost 7 years ago
because:
A: I don't know if I'll need to add more subnets or AZs in the future
B: I don't think that cidrsubnets() will accurately chop up the cidr blocks into my subnets consistently
cabrinha
cabrinhaalmost 7 years ago
is there a better way to go about this other than hard coding the /24's I want to assign to certain subnets?
cabrinha
cabrinhaalmost 7 years ago(edited)
I'm guessing there is some magic I'm missing with cidrsubnets(var.vpc_cidr_block, N, length(var.aws_azs)) or something like that
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
take a look at our subnet modules
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
we factor in a "max subnets" fudge factor
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
so it will slice and dice it based on the max
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
but allocate the number you need now
Callum Robertson
Callum Robertsonalmost 7 years ago
Hey team, is there a way to pass the assumed role credentials for the provider into a null resource local exec provisioner?
Callum Robertson
Callum Robertsonalmost 7 years ago
@Erik Osterman (Cloud Posse) have you ever done anything like this?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
my gut tells me it should just work
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
the environment variables are inherited
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
ah, but we assume before we call terraform
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
i'm guessing you're assuming in terraform
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
then no-go
Callum Robertson
Callum Robertsonalmost 7 years ago
assuming in terraform
Callum Robertson
Callum Robertsonalmost 7 years ago
Uhhh!
Callum Robertson
Callum Robertsonalmost 7 years ago
painful
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
not sure how you'll work around that one
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
fwiw, we assume role with vault
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
then call terraform
Callum Robertson
Callum Robertsonalmost 7 years ago
yeah, right now I'm assuming a role with a provider block that uses the session token I have in my local machines env
Callum Robertson
Callum Robertsonalmost 7 years ago
so I'm assuming it uses my local environment variables and not those assumed in terraform?
Callum Robertson
Callum Robertsonalmost 7 years ago
Found this, sounds like an awesome idea
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago

    environment {
      AWS_ACCESS_KEY_ID = "${data.aws_caller_identity.current.access_key}"
      AWS_ACCESS_KEY_ID = "${data.aws_caller_identity.current.secret_key}"
    }
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
clever
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
didn't know they were available like that
Callum Robertson
Callum Robertsonalmost 7 years ago
they're not right now =[
Callum Robertson
Callum Robertsonalmost 7 years ago
Hoping Hashicorp review the pull request and get it added in
Callum Robertson
Callum Robertsonalmost 7 years ago
looks like the secrets get persisted in the statefile however, so will need some workaround on that
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago(edited)
what are you trying to solve? ... using local exec
Callum Robertson
Callum Robertsonalmost 7 years ago
aws s3 sync
Callum Robertson
Callum Robertsonalmost 7 years ago
for bucket objects
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
aha
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
yea, i've had that pain before
Callum Robertson
Callum Robertsonalmost 7 years ago
Looks like I'll have to keep this seperate from my tf configuration
Callum Robertson
Callum Robertsonalmost 7 years ago
and put it into a build pipeline of sorts
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
do you strictly need to use aws s3 sync?
Callum Robertson
Callum Robertsonalmost 7 years ago
maybe just a stage that jenkins runs
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
e.g. non deterministic list of files
Callum Robertson
Callum Robertsonalmost 7 years ago
yeah, it's just a sprawling directory of web assets
Callum Robertson
Callum Robertsonalmost 7 years ago
the TF resource for bucket upload with single object from memory (this was a while ago)
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
sooooo
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
what about using local exec to build a list of files?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
then use raw terraform to upload them
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
e.g. call find
Callum Robertson
Callum Robertsonalmost 7 years ago
could you give me an example?
loren
lorenalmost 7 years ago
You could try using local-exec to build an aws config profile with the assume role config, then pass the --profile option to aws-cli?
PePe Amengual
PePe Amengualalmost 7 years ago(edited)
this is what I do to assume role :
aws-vault exec PROFILE -- terraform apply -var 'region=us-east-2' -var-file=staging.tfvars 
in my local machine
PePe Amengual
PePe Amengualalmost 7 years ago
providers.conf
provider "aws" {
  region = var.region

  # Comment this if you are using aws-vault locally
  assume_role {
    role_arn = var.role_arn
  }
}
PePe Amengual
PePe Amengualalmost 7 years ago
jenkins with and instance profile uses straight terraform
PePe Amengual
PePe Amengualalmost 7 years ago
the role arn is passed as a var
PePe Amengual
PePe Amengualalmost 7 years ago
pretty easy
Callum Robertson
Callum Robertsonalmost 7 years ago
yeah, I'm using AWS-VAULT as well but right now it assumes security account credentials with MFA to get the state file and lock in the state bucket
Callum Robertson
Callum Robertsonalmost 7 years ago
I've just made this a stage that my jenkins host runs with it's instance profile as you suggested @PePe Amengual
Callum Robertson
Callum Robertsonalmost 7 years ago
Thanks all!
Laurynas
Laurynasalmost 7 years ago
Hi, how can I pass environemnt variables from file using https://github.com/cloudposse/terraform-aws-ecs-container-definition
Mike Whiting
Mike Whitingalmost 7 years ago(edited)
I've managed to deploy multiple task definitions and services to an AWS ECS service using terraform but now am stumped at simple services discovery. I don't want to use service discovery through Route53 as this seems overkill for now when the deployed services (docker containers) exist on the same host ECS EC2 instance. Does anyone have any recommendations beyond using docker inspect and grep to discover the subnet IP address ?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
Consul?
cabrinha
cabrinhaalmost 7 years ago(edited)
Istio? AppMesh? Consul is really good though, I would check that out.
cabrinha
cabrinhaalmost 7 years ago
has anyone gotten terraform 0.12 syntax checking and highlighting to work with VSCode?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
not sure if helpful
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago(edited)
also, there's someone in this channel that has been working on something for vscode/HCL2 I think
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
but i can't remember who it was
MattyB
MattyBalmost 7 years ago
https://github.com/mauve/vscode-terraform/issues/157#issuecomment-547690010
I've had it working for a couple of weeks. It's stable but not 100% functionality
MattyB
MattyBalmost 7 years ago
crud, i grabbed the wrong link. it's the next reply
Julio Tain Sueiras
Julio Tain Sueirasalmost 7 years ago
What’s up? @Erik Osterman (Cloud Posse)
Julio Tain Sueiras
Julio Tain Sueirasalmost 7 years ago
@MattyB will fix most of the issues, been busy with preparing for release of the terraform provider for azuredevops
MattyB
MattyBalmost 7 years ago
No worries. It does what I need. Thanks!
Julio Tain Sueiras
Julio Tain Sueirasalmost 7 years ago
Anybody here use azuredevops , just curious
vitaly.markov
vitaly.markovalmost 7 years ago(edited)
hi @Andriy Knysh (Cloud Posse) @Igor Rodionov I’ve been trying to setup an EKS cluster using this module setup node groups https://github.com/cloudposse/terraform-aws-eks-workers, how I can set a list of labels to kube node ? thank you in advance
kskewes
kskewesalmost 7 years ago(edited)
How is everyone breaking up their Terraform stack for an 'environment' ?
We have shared out by provider (aws/gitlab/etc) but with a migration to AWS am looking at breaking out our AWS within an environment.
This means multiple state files, some copies into variables files and a dependency order for standing up the whole environment, but does limit blast radius for changes. We put multiple state files into the same s3 bucket using the CP s3 backend module. (thank you!)
Very rough tree output in thread.
Phuc
Phucalmost 7 years ago
Hi guys, quick question. Is this required to createa ECS cluster first, then you can deploy ECS service using fargate type on that cluster ?
Saichovsky
Saichovskyalmost 7 years ago
Hi everyone

I have a burning question on terraform <> AWS

resource "aws_kinesis_analytics_application" "app" {
  name = var.analytics_app_name
  tags = local.tags

  // TODO: need to make inputs & outputs dynamic -- cater for cases of multiple columns, e.t.c.
  //  inputs {
  //    name_prefix = ""
  //    "schema" {
  //      "record_columns" {
  //        name = ""
  //        sql_type = ""
  //      }
  //      "record_format" {}
  //    }
  //  }
  //  outputs {
  //    name = ""
  //    "schema" {}
  //  }
}


Here’s my quandary - number of columns is not fixed
Phuc
Phucalmost 7 years ago
hi guys, is cloudposse ecs cluster module come with draining lambda function as well ?
Mike Whiting
Mike Whitingalmost 7 years ago(edited)
@Erik Osterman (Cloud Posse) thanks 🙂
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
@Jake Lundberg (Coder) maybe something for you...
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
I believe you were saying a lot of your customers were asking about integration of terraform cloud with azure devops
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
@Julio Tain Sueiras has something for you 😉 ☝️
Julio Tain Sueiras
Julio Tain Sueirasalmost 7 years ago
@Erik Osterman (Cloud Posse) in this case is different A) https://www.hashicorp.com/blog/announcing-azure-devops-support-for-terraform-cloud-and-enterprise/ and B) the one that jake mention is probably TF Cloud to hook to AzureDevOps Repos
Julio Tain Sueiras
Julio Tain Sueirasalmost 7 years ago
where as the provider purpose to manage all components of azuredevops with terraform
cabrinha
cabrinhaalmost 7 years ago(edited)
when I have a parameter like this:

// Add environment variables.
  environment {
    variables {
      SLACK_URL = "${var.slack_url}"
    }
  }
How can I parameterize it?
cabrinha
cabrinhaalmost 7 years ago
the value of "variables" needs to be some kind of dynamic map
cabrinha
cabrinhaalmost 7 years ago
with any number of key/value pairs
cabrinha
cabrinhaalmost 7 years ago
When I try:
  // Add environment variables.
  environment {
    variables {
      "${var.env_vars}"
    }
  }
... where var.env_vars is a map ... I get an error
cabrinha
cabrinhaalmost 7 years ago
key '"${var.env_vars}"' expected start of object ('{') or assignment ('=')
cabrinha
cabrinhaalmost 7 years ago
vitaly.markov
vitaly.markovalmost 7 years ago
I’ve found another not obvious behavior in case when we create two or more node groups (https://github.com/cloudposse/terraform-aws-eks-workers) then trafiek beetween pods in diferent node groups is not allowed due to SG missconfiguration,

So the podA in the ng-1 cannot to send request to podB in ng-2
zeid
zeidalmost 7 years ago
There is a Microsoft effort for a terraform provider for azure devops. Would be good to consolidate efforts https://github.com/microsoft/terraform-provider-azuredevops
cabrinha
cabrinhaalmost 7 years ago
So, I'm trying to write an AWS Lambda module that can automatically add DataDog Lambda layers to the caller's lambda...
cabrinha
cabrinhaalmost 7 years ago
I don't think I can do terraform data lookup on the Lambda layer in DataDog's account, so I'm trying to write a python script for my own external data lookup
cabrinha
cabrinhaalmost 7 years ago
data "external" "layers" {
  program = ["python3", "${path.module}/scripts/layers.py"]
  query = {
    runtime = "${var.runtime}"
  }
}
cabrinha
cabrinhaalmost 7 years ago(edited)
but, what I'm having an issue with right now, is how Python interprets the "query" parameter inside my program. The docs say it's a JSON object ... but depending on how I read it, it seems to come in as a set() or a io.TextWrapper
PePe Amengual
PePe Amengualalmost 7 years ago
did Hashicorp changed the font on the Doc site ?
Julio Tain Sueiras
Julio Tain Sueirasalmost 7 years ago
If you mean the general revamp and adding search then yes
cabrinha
cabrinhaalmost 7 years ago(edited)
yeah, the fonts changed too -- and I don't like them! 😅
erik
erikalmost 7 years ago
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
so, out of familiarity, I liked the old "default" font, but it feels quite readable to me.
PePe Amengual
PePe Amengualalmost 7 years ago
do you know anyone in hashicorp to complain ?
PePe Amengual
PePe Amengualalmost 7 years ago
I hope the search is better 🙂
vitaly.markov
vitaly.markovalmost 7 years ago
I can’t find a solution how to format map to string, an example below:

input: { purpose = "ci_worker", lifecycle = "Ec2Spot" }
output: "purpose=ci_worker,lifecycle=Ec2Spot" 

Any ideas? 🙂
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
yes, i've done this before in 0.11 syntax
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
1. use null_resource with count to create a list of key=value pairs
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
2. use join with splat to aggregate them with ,
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
maybe some more elegant way in HCl2
cabrinha
cabrinhaalmost 7 years ago
I think I'm getting bit by a really strange error: https://github.com/hashicorp/terraform/issues/16856
cabrinha
cabrinhaalmost 7 years ago(edited)
yeah, I'm trying to determine if the user has set "var.enable_datadog" to "true"; If they have then:
layers = [ list(var.layers, local.dd_layer) ]  
  else: 
layers = [ var.layers ]
cabrinha
cabrinhaalmost 7 years ago
  layers                         = [
    "${var.enable_datadog ? "${local.dd_layer}:${data.external.layers.result["arn_suffix"]}" : var.layers }"
  ]
cabrinha
cabrinhaalmost 7 years ago
Error: module.lambda.module.lambda.aws_lambda_function.lambda: layers: should be a list
cabrinha
cabrinhaalmost 7 years ago
even when I remove the local, I get the same error:
  layers                         = [
    "${var.enable_datadog ? data.external.layers.result["arn_suffix"] : var.layers }"
  ]
cabrinha
cabrinhaalmost 7 years ago(edited)
so for some reason, data.external along with locals that are not strings seem to be the culprits here
PePe Amengual
PePe Amengualalmost 7 years ago
Hi Guys : I’m using https://github.com/cloudposse/terraform-aws-s3-log-storage and I created a bucket that is receiving logs but I can download them, copy nothing not from the root account or anything
fw123
fw123almost 7 years ago
any terragrunt experts here that i can pm a question to
vitaly.markov
vitaly.markovalmost 7 years ago
I’ve opened a PR with hint to avoid another unexpected behaviour - mismatch kubelet versions on control plane and node groups https://github.com/cloudposse/terraform-aws-eks-cluster/pull/32
Andrew Roth
Andrew Rothalmost 7 years ago
I need to stand up AWS Directory Service. I would love to maintain the users and groups as configuration as code with gitops. Anybody done that before?
Maciek Strömich
Maciek Strömichalmost 7 years ago
Laurynas
Laurynasalmost 7 years ago
Hi, is it possbile to read locals from file in terraform?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
Sorta
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
You can load a json file into a local
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
Or yaml
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
C
Cloud Possealmost 7 years ago
:zoom: Join us for "Office Hours" every Wednesday 11:30AM (PST, GMT-7) via Zoom.

This is an opportunity to ask us questions on terraform and get to know others in the community on a more personal level. Next one is Nov 20, 2019 11:30AM.

👉️ Register for Webinar

:slack: #office-hours (our channel)
Blaise Pabon
Blaise Pabonalmost 7 years ago
One of my discomforts with Terraform has been the paucity of testing and verification... It looks like Hashicorp got the memo ; this just in from Berlin:
https://speakerdeck.com/joatmon08/test-driven-development-tdd-for-infrastructure
Laurynas
Laurynasalmost 7 years ago
Any pointers on what is the best practice in creating multiple AWS console iam users using terraform?
Dinesh Patra
Dinesh Patraalmost 7 years ago
We as a team are evaluating Terraform Enterprise..vs Terraform Opensource.. does anyone see value add in Enterprise version
John H Patton
John H Pattonalmost 7 years ago
Hello Everyone. I'm having an issue with ACM and I'm hoping someone knows why this is happening or how to troubleshoot further. I'm creating an LB config with an HTTPS listener and with the following module configuration:

module "cert" {
  source                            = "git::<https://github.com/cloudposse/terraform-aws-acm-request-certificate.git?ref=0.4.0>"
  zone_name                         = local.zone
  domain_name                       = local.origin_dns
  subject_alternative_names         = local.origin_san
  ttl                               = "300"
  process_domain_validation_options = true
  wait_for_certificate_issued       = true
}
cabrinha
cabrinhaalmost 7 years ago(edited)
hello there
cabrinha
cabrinhaalmost 7 years ago
can anyone tell me how to use the https://www.terraform.io/docs/providers/aws/d/autoscaling_groups.html to select an ASG based on it's tags?
cabrinha
cabrinhaalmost 7 years ago
Specifically, I'm confused on the filters:

  filter {
    name   = "key"
    values = ["Team"]
  }

  filter {
    name   = "value"
    values = ["Pets"]
  }
cabrinha
cabrinhaalmost 7 years ago
so, what I'm thinking is:

  filter {
    name   = "key"
    values = ["tag:Name"]
  }

  filter {
    name   = "value"
    values = ["my-name-tag-value"]
  }
cabrinha
cabrinhaalmost 7 years ago
does that seem right?
Jeff Young
Jeff Youngalmost 7 years ago
Good Morning anyone run into this?
Initializing provider plugins...
- Checking for available provider plugins...

Error verifying checksum for provider "okta"

Terraform v0.12.13
Linux somevm0 4.15.0-66-generic #75-Ubuntu SMP Tue Oct 1 05:24:09 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
Hrmmmm no haven't seen that one.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
maybe blow away your .terraform cache directory and try agian?
Adrian
Adrianalmost 7 years ago
mismatch between ~/.terraform.d/plugins/[octa_provider_file] and terraform state checksum of this file?
johncblandii
johncblandiialmost 7 years ago(edited)
I have some mangled state locally and am moving it to TF Cloud so manual state management…yayyyy. 😞


-/+ module.eks_cluster.aws_eks_cluster.default (new resource required)
      id:                                                     "mycluster" => <computed> (forces new resource)
      arn:                                                    "arn:aws:eks:us-west-2:xxxxxxx:cluster/mycluster" => <computed>


^ This is a concern. Normally I wouldn’t sweat a new resource, but if this destroys the EKS cluster… 💥 goes my week restoring everything. So my question is……..will this really delete the resource IF the id is the exact same as the live instance?

This is using https://github.com/cloudposse/terraform-aws-eks-cluster.git?ref=0.4.0 as the module source.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
Yes, what ever is causing your new ID to be generated will force a new cluster
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
I don't think there's a way to avoid that
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
fwiw, @Andriy Knysh (Cloud Posse) is working on tf cloud support in our EKS modules
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
we have some PRs for this open now that will get merged by EOD
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
johncblandii
johncblandiialmost 7 years ago
I pretty much knew the answer, but had to sanity check. the thing is…the id shouldn’t be new. it should be the exact same
johncblandii
johncblandiialmost 7 years ago
well lookie there…kctl is a great addition. we do that separately right now
Ben Clapp
Ben Clappalmost 7 years ago
Hi there! We’re using this module for EKS https://github.com/cloudposse/terraform-aws-eks-cluster, and currently trying to setup the mapping for IAM roles to k8s service accounts. According to https://docs.aws.amazon.com/eks/latest/userguide/enable-iam-roles-for-service-accounts.html, we need to grab the OIDC issuer URL from the EKS cluster and add it to the aws_iam_openid_connect_provider resource.

Has anyone come across this? Unfortunately can’t evaluate the eks_cluster_id output variable from the eks cluster module into a data lookup for the aws_eks_cluster data source. Perhaps we add an output to the eks module for the identity output from aws_eks_cluster? Happy to do a PR for it
Chris Fowles
Chris Fowlesalmost 7 years ago
if you're using .net on eks beware of this: https://github.com/aws/aws-sdk-net/issues/1413
Chris Fowles
Chris Fowlesalmost 7 years ago
also make sure you add a thumbprint to the openid connect provider:
resource "aws_iam_openid_connect_provider" "this" {
  client_id_list  = ["<http://sts.amazonaws.com|sts.amazonaws.com>"]
  thumbprint_list = [
    "9e99a48a9960b14926bb7f3b02e22da2b0ab7280" # <https://github.com/terraform-providers/terraform-provider-aws/issues/10104#issuecomment-545264374>
  ]
  url             = "${aws_eks_cluster.this.identity.0.oidc.0.issuer}"
}
Chris Fowles
Chris Fowlesalmost 7 years ago
these are the things that i ran into over the last week dealing with IAM for service account
Ben Clapp
Ben Clappalmost 7 years ago
Thanks for the heads up! Luckily no .net, but could be similar risks with some of the other pods we’re running
Ben Clapp
Ben Clappalmost 7 years ago
Unfortunately we can’t do something similar to "${aws_eks_cluster.this.identity.0.oidc.0.issuer}" to get the oidc issuer URL as we’re using this module, which doesn’t have this as an output https://github.com/cloudposse/terraform-aws-eks-cluster
Chris Fowles
Chris Fowlesalmost 7 years ago
is the cluster id output the cluster name?
Chris Fowles
Chris Fowlesalmost 7 years ago
we don't use the module unfortunately so i don't know
Chris Fowles
Chris Fowlesalmost 7 years ago
right - you said it wasn't up above 😛
Chris Fowles
Chris Fowlesalmost 7 years ago
i've had some success using the arn datasource to parse names out of arns:
Chris Fowles
Chris Fowlesalmost 7 years ago
but ideally it would be an output from the eks module
Ben Clapp
Ben Clappalmost 7 years ago(edited)
Yea, one of the outputs of the module is the EKS cluster name. With this we could use with the aws_eks_cluster datasource like you’ve done above… however doesn’t seem like we can do an indirect variable reference like with evalin bash.

Ideally would want to be able to have something like "${data.aws_eks_cluster.${module.eks_cluster_01.eks_cluster_id}.identity.0.oidc.0.issuer}"
Ben Clapp
Ben Clappalmost 7 years ago
Simplest way feels like a PR to the eks cluster module to output this variable 🙂
Ben Clapp
Ben Clappalmost 7 years ago
Thanks for the suggestions though @Chris Fowles! Good to have warnings that the IAM Roles to svc accounts isn’t the magic bullet we were expecting it to be
MattyB
MattyBalmost 7 years ago
Anyone have a good article/blog/post/etc.. on directory structures for more complex architectures? I've gone through a few blogs, and threads on reddit, but haven't quite understood how to break mine down to be as simple as theirs. I have a lot of variables & modules compared to others. Maybe part of it is on me. For my PoC(proof of concept but PoS might be more like it) I'm declaring quite a few variables, env vars for example, and making quite a few module references. If I want to use the same architecture for all of my environments it's all fine and dandy because I can just have another tfvars file but that doesn't seem like a great idea 🙂 thanks for the feedback.
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 7 years ago
@Ben Clapp PRs are welcome 🙂
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 7 years ago
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 7 years ago
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 7 years ago
not sure I understand this
Yea, one of the outputs of the module is the EKS cluster name. With this we _could_ use with the `aws_eks_cluster` datasource like you've done above… however doesn't seem like we can do an indirect variable reference like with `eval`in bash
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 7 years ago
since the module outputs cluster name, you can use https://www.terraform.io/docs/providers/aws/d/eks_cluster.html to read all other attributes
Ben Clapp
Ben Clappalmost 7 years ago
Correct me if I’m wrong, but I think going down that path, we’d have to have something like this right? "${data.aws_eks_cluster.${module.eks_cluster_01.eks_cluster_id}.identity.0.oidc.0.issuer}"

E.g. evaluate the cluster name, and then use the cluster name as part of the data lookup against aws_eks_cluster?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 7 years ago
the example here https://www.terraform.io/docs/providers/aws/d/eks_cluster.html shows exactly what you need to do
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 7 years ago(edited)

module "eks_cluster" {
  source                 = "../../"
  namespace              = var.namespace
  stage                  = var.stage
  name                   = var.name
  attributes             = var.attributes
  tags                   = var.tags
  region                 = var.region
  vpc_id                 = module.vpc.vpc_id
  subnet_ids             = module.subnets.public_subnet_ids
  kubernetes_version     = var.kubernetes_version
  kubeconfig_path        = var.kubeconfig_path
  local_exec_interpreter = var.local_exec_interpreter

  configmap_auth_template_file = var.configmap_auth_template_file
  configmap_auth_file          = var.configmap_auth_file

  workers_role_arns          = [module.eks_workers.workers_role_arn]
  workers_security_group_ids = [module.eks_workers.security_group_id]
}

data "aws_eks_cluster" "example" {
  name = module.eks_cluster.eks_cluster_id
}

locals {
	oidc_issuer = data.aws_eks_cluster.example.identity.0.oidc.0.issuer
}
Ben Clapp
Ben Clappalmost 7 years ago
Of course! Didn’t think to create the data source first, and then get the variable from that, this is exactly what we need 🙂
Ben Clapp
Ben Clappalmost 7 years ago
Thanks heaps for the help @Andriy Knysh (Cloud Posse)
james
jamesalmost 7 years ago
any ECS users here? we’re considering a migration into ECS (from vanilla docker on EC2) but I couldn’t find much in the way of existing ECS modules in the module directory
james
jamesalmost 7 years ago
does it play well with Terraform?
vFondevilla
vFondevillaalmost 7 years ago
yep
vFondevilla
vFondevillaalmost 7 years ago
I’m using it for managing our task definitions and services
vFondevilla
vFondevillaalmost 7 years ago
and is pretty simple and straightforward
MattyB
MattyBalmost 7 years ago
https://github.com/cloudposse/terraform-aws-ecs-web-app
using it right now. super simple to setup
Laurynas
Laurynasalmost 7 years ago
Hi, sometimes when terraform has to destroy and recreate ecs service I get a following error: InvalidParameterException: Unable to Start a service that is still Draining. What causes it and how can I fix that?
Nick V
Nick Valmost 7 years ago
Is there a way to show the output of terraform plan from a plan file? In 0.11 you just did terraform show but in 0.12 I'm just getting resource names without changes
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago(edited)
maybe terraform apply -auto-approve=false $PLANFILE < /dev/null
Brij S
Brij Salmost 7 years ago
im trying to create a custom domain with api gateway, but i am using count to create two types of r53 records. Im using count for api_gateway as a conditional, which I would also like to use for the r53 records:

resource "aws_api_gateway_domain_name" "domain" {
  count           = var.create_custom_domain == "true" ? 1 : 0
  certificate_arn = var.aws_acm_certificate_arn
  domain_name     = var.domain_name
}

resource "aws_route53_record" "domain" {
  count = length(var.route53_record_types)
  name    = aws_api_gateway_domain_name.domain.domain_name
  type    = var.route53_record_types[count.index]
  zone_id = "xxxxxxxxxx"

  alias {
    evaluate_target_health = false
    name                   = aws_api_gateway_domain_name.domain.cloudfront_domain_name
    zone_id                = aws_api_gateway_domain_name.domain.cloudfront_zone_id
  }
}

can count have & ?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 7 years ago
count  = var.create_custom_domain ? length(var.route53_record_types) : 0                 
Brij S
Brij Salmost 7 years ago
now I get this:
Error: Missing resource instance key

  on ../modules/frontend/main.tf line 263, in resource "aws_route53_record" "domain":
 263:     name                   = aws_api_gateway_domain_name.domain.cloudfront_domain_name

Because aws_api_gateway_domain_name.domain has "count" set, its attributes
must be accessed on specific instances.

For example, to correlate with indices of a referring resource, use:
    aws_api_gateway_domain_name.domain[count.index]


Error: Missing resource instance key

  on ../modules/frontend/main.tf line 264, in resource "aws_route53_record" "domain":
 264:     zone_id                = aws_api_gateway_domain_name.domain.cloudfront_zone_id

Because aws_api_gateway_domain_name.domain has "count" set, its attributes
must be accessed on specific instances.

For example, to correlate with indices of a referring resource, use:
    aws_api_gateway_domain_name.domain[count.index]
Brij S
Brij Salmost 7 years ago
but apig is only 1 resource, why reference by count?
loren
lorenalmost 7 years ago(edited)
it's a tf0.12 change. when a resource is using count, references to its attributes must use the index. in tf0.11 you could reference it directly (sometimes), but in tf0.12 it is strict about using the index. e.g.

name                   = aws_api_gateway_domain_name.domain[0].cloudfront_domain_name
Brij S
Brij Salmost 7 years ago
sweet that did it 🙂 tf12 is funky
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 7 years ago
better to use it with splat+join like this
join("", aws_api_gateway_domain_name.domain.*.cloudfront_domain_name)
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 7 years ago
somebody already had issues with using [0]
loren
lorenalmost 7 years ago(edited)
✋️ it kind of depends on the module and where the index is being used, but yeah for belt and suspenders purposes can splat+join, or use the ternary to conditionally reference the index value (if you want a different/specifc value when the count == 0 for the referenced resource)

name = length(aws_api_gateway_domain_name.domain) > 0 ? aws_api_gateway_domain_name.domain[0].cloudfront_domain_name : null
Gabe
Gabealmost 7 years ago
Hey all, new here and still new to Terraform - I’m trying to use Terraform to configure an AWS CodePipeline. It will plan and apply just fine, but the pipeline fails in the real world every time at the source stage. It seems to need additional S3 permissions and I haven’t yet figured out how to provide them. The error is Insufficient permissions The provided role does not have permissions to perform this action. Underlying error: Access Denied (Service: Amazon S3; Status Code: 403; Error Code: AccessDenied; Request ID:... I’ve tried a blanket S3 allow-all permission policy on both the pipeline’s associated role and the codebuild’s associated role (desperation) to no avail. - anyone got any advice?
Bruce
Brucealmost 7 years ago
Hey @Gabe you could always try creating the pipeline with the AWS CLI and use --debug to see what permission error your getting. It's not always clear but sometimes another AWS API will call another... It's helped me out in the past.
Andy
Andyalmost 7 years ago
@Bruce To add on to your point (Though it clearly seems to be a perm issue), search for Traceback in aws_cli_command --debug 2>&1 | less -S
Maciek Strömich
Maciek Strömichalmost 7 years ago
Laurynas
Laurynasalmost 7 years ago
Hi, have you ever experienced that when terraform apply fails sometimes not all created resources are written into terraform state? I had an issue with one terraform module but when fixed that terraform was trying to create resources that were already created ....
Milos Backonja
Milos Backonjaalmost 7 years ago
Hi all, how you handle ssh keys with terraform/terragrunt?
I have used https://github.com/cloudposse/terraform-aws-key-pair for bastion and for all other instances in private subnets?
Its ok untill some point, but if you delete terragrunt cache or you work in team it can be issue, since it will try to recreate keys, and depends on configuration other resources depedent on those keys. I am looking for solution which can be used for safe/secure ssh keys sharing and distributing. to all instances, and I am wondering what other people use.
Thanks
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
This is what we use
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
The other stuff is just for very simple use cases
Richy de la cuadra
Richy de la cuadraalmost 7 years ago
what about unknow token IDENT error?
Richy de la cuadra
Richy de la cuadraalmost 7 years ago
I’m using terraform v0.11.13
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
This is always a mismatch between HCL2 and terraform 0.11
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 7 years ago
it’s when you using TF 0.11 on modules converted to 0.12
Richy de la cuadra
Richy de la cuadraalmost 7 years ago
you right, i need to modify some resources
vitaly.markov
vitaly.markovalmost 7 years ago
How to create a new terraform module to follow cloudposse`s practices? I didn’t find any templates in https://github.com/cloudposse @Erik Osterman (Cloud Posse) could you help me ? 🙂 I’m going to create a module similar to https://github.com/cloudposse/terraform-aws-kops-external-dns
Brij S
Brij Salmost 7 years ago
with TF12, is the * not allowed for multiple resources? for example,
aws_api_gateway_domain_name.domain[*].domain_name gives an error saying a string is required. I'm trying to create multiple api-gateway custom domains(from a list) then have the appropriate records be created in route53 for each domain
Adrian
Adrianalmost 7 years ago
@Erik Osterman (Cloud Posse) why you did'nt include
label_order = var.label_order
in
module "label" {
  source     = "git::<https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.14.1>"
  enabled    = var.enabled
  namespace  = var.namespace
  name       = var.name
  stage      = var.stage
  delimiter  = var.delimiter
  attributes = var.attributes
  tags       = var.tags
}

https://github.com/cloudposse/terraform-aws-elasticsearch/blob/master/main.tf
Adrian
Adrianalmost 7 years ago
I need to fork it and add this line 😕, it is possible to make some PR for that kind of change?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
we just haven't gone through all our modules to add all the parameters
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
we'll approve if you open the PR
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
ping @Andriy Knysh (Cloud Posse)
Adrian
Adrianalmost 7 years ago
thnx
Adrian
Adrianalmost 7 years ago
btw, nice to have modules from CloudPosse
Adrian
Adrianalmost 7 years ago
Bruce
Brucealmost 7 years ago
Does anyone have a good example of a lambda that will notify a slack channel of a role change? For example when an engineer switches role to a admin role it fires a notification to slack. Was going to pull one together but didn't want to reinvent the wheel if it's been done before... Seems like it has.
loren
lorenalmost 7 years ago(edited)
the aws-to-slack thing is easy enough. sounds like you need to define the actual event though, to trigger the notification. that event would be either CWE or SNS.... probably CWE in this case, with a pattern filtering on cloudtrail events for the sts:AssumeRole* action?
Bruce
Brucealmost 7 years ago
That was I was thinking my approach would be @loren thanks!😁
vFondevilla
vFondevillaalmost 7 years ago
I have a question about terraform and multiple git identities. I have multiple git repositories (some of them on gitlab) but in gitlab you can’t have the same ssh key in 2 different users. I configured git to use another ssh key for the work repositories, but when Terraform is sourcing a module, it will use the main identity (my personal one) without access to my employer private repos. There’s any way of managing this I’m unaware of?
Mateusz Kamiński
Mateusz Kamińskialmost 7 years ago(edited)
I would arrange one user to have access to all those repos - isn't it possible?
vFondevilla
vFondevillaalmost 7 years ago
Nope. Is not possible to use personal users for accessing the company repos by policy
Steven
Stevenalmost 7 years ago
What about company user on personal repos or fork the repos
vFondevilla
vFondevillaalmost 7 years ago
that’s one of the possibilities I have in mind, but i’d prefer to keep everything separated 😂
loren
lorenalmost 7 years ago
Terraform uses go-getter under the covers, so maybe it has some tricks that would help... https://github.com/hashicorp/go-getter/blob/master/README.md#git-git
loren
lorenalmost 7 years ago
Use a terraform override file to set your ssh key for each nested module source...
vFondevilla
vFondevillaalmost 7 years ago
oh! nice
vFondevilla
vFondevillaalmost 7 years ago
i’ll take a look thx!
MattyB
MattyBalmost 7 years ago
Using your terraform-aws-rds module as an example, it looks like the parameter groups, subnet groups, and security group resources are tightly coupled with the instance. Is there a reason I shouldn't design an rds module for those resources to be passed in? If I have a large number of instances (DB, ALB, ECS, etc...) it seems like it'd be good practice to create fewer dependent resources. Thoughts?
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
@MattyB sounds correct
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 7 years ago
for security groups, we usually create a separate one for the module, and then provide allowed_security_groups and allowed_cidr_block to allow to connect to the SG https://github.com/cloudposse/terraform-aws-rds/blob/master/main.tf#L139
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 7 years ago
parameter group implemented using dynamic block so you can add as many params as you need (or provide an empty list for no params) https://github.com/cloudposse/terraform-aws-rds/blob/master/main.tf#L77
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 7 years ago
for subnet_group you just provide the subnets where to provision RDS instances https://github.com/cloudposse/terraform-aws-rds/blob/master/main.tf#L124 (so not really much to configure here)
MattyB
MattyBalmost 7 years ago
Helpful as usual 🙂 thanks!
John H Patton
John H Pattonalmost 7 years ago
I've worked through the ACM module and updated it to allow for a SAN that includes records not in a passed in zone...
kskewes
kskewesalmost 7 years ago
Hey team, thanks for all the modules. Am standing up this one: https://github.com/cloudposse/terraform-aws-elasticache-redis
Couple thoughts:
1. Be good to recommend a secure auth_token, we are internally using random_password. Have submitted PR for this, happy to iterate or close if not suitable.
2. Security Groups and cidr_block's. There are a couple of PR's that look useful for us to control what/where can talke to Redis and vice versa. ie: supply own security group and/or cidr_block for ingress. Anything I can do to help them along? We will carry fork for now.
vitaly.markov
vitaly.markovalmost 7 years ago
I’ve opened a PR, added a variable to create OIDC provider, then can be used by other modules, I also going to add modules that create IAM roles for cluster-autoscaler, ExternalDNS, etc https://github.com/cloudposse/terraform-aws-eks-cluster/pull/36
curious deviant
curious deviantalmost 7 years ago
* Seeking Guidance/Opinions *

We have a situation where in the team is trying to host multiple apps in a single VPC ( still debating this arch). I personally would like to have them in separate VPCs and not manage the entire infrastructure as it grows as a monolith managed via a single TF repo (also have network isolation b/w them). In case having a single VPC is the route to go , would it be possible to manage the shared infrastructure (VPC) through 1 repo and manage the components within it via app repos? Is it a good way even of managing infrastructure ? Can the reference in the app repos to the shared VPC be dynamic in that case or would we need to hardcode VPC, Subnet IDs etc.. ? Anything else we should be wary of ?
ismail
ismailalmost 7 years ago(edited)
Hi all,
I am facing some issues in my terraform code. I am trying to transfer a file using null_resource on aws instance. But getting error

host        = module.ec2.public_ip
Inappropriate value for attribute "host": string required.


Here is the code being used:

resource "null_resource" "test" {
  provisioner "file" {
    source      = file(var.source_path)
    destination = file(var.destination_path)
    //    on_failure  = "continue"
    connection {
      type        = "ssh"
      user        = var.ssh_user
      private_key = var.ssh_key
      host        = module.ec2.public_ip
    }
  }
}
Lewis
Lewisalmost 7 years ago
Hello All,

Does anyone know how to delete the webhooks after?

We currently create a new webhook everytime we do a deployment and keep maxing out our webhook limit, we would like a way to delete the previous webhooks prior or just install the webhook for a one time use.

Kind regards,
Lewis
Laurynas
Laurynasalmost 7 years ago
Anyone experience weird Error: Cycle: errors after updating to 0.12.15 from 0.12.12?
Laurynas
Laurynasalmost 7 years ago
it looks like I need to downgrade the terraform. How can i do that without loosing the state?
nutellinoit
nutellinoitalmost 7 years ago
do you have the remote state on s3 versioned?
Laurynas
Laurynasalmost 7 years ago
yes.It's remote on s3 with versioning
Steven
Stevenalmost 7 years ago
Then I'd restore the prior version and remove its record in DynamoDB
C
Cloud Possealmost 7 years ago
:zoom: Join us for "Office Hours" every Wednesday 11:30AM (PST, GMT-7) via Zoom.

This is an opportunity to ask us questions on terraform and get to know others in the community on a more personal level. Next one is Nov 27, 2019 11:30AM.

👉️ Register for Webinar

:slack: #office-hours (our channel)
kskewes
kskewesalmost 7 years ago
Hey team, is anyone using the data source for security_groups a lot to enable lookup and extension of allowed_security_group variable in various modules?
We use a few state files to limit blast radius and have a chicken & egg situation.
Contrived example:
1. if we want to allow bastion to connect to RDS, we need to provision bastion and its SG before we can provision RDS SG. Or:
2. if we use the data source, then we can provision RDS (bastion SG data source empty?) and then provision bastion, then reapply RDS in order to add the bastion SG (data source returns SG id).
Option 2 means we may have to do a couple of terraform apply to bring certain things up but still gives us small blast radius.
Third option is to centrally define all SG's and then specify them in other state files but that gives us a massive blast radius.
We started using cidr_blocks but with the way our subnets are defined they don't map to workloads, ie: subnets are shared by different workloads with different requirements
Laurynas
Laurynasalmost 7 years ago
Hi, what's your strategy for updating terraform? How often should I update to the latest version? How long after a new version is realeased is better to wait until I can use the newer version in production
MattyB
MattyBalmost 7 years ago
Using semver.org I stay patch-1 behind and plan on letting the release work it's way through testing & staging before it hits production. Reverting the version is a super simple docker change.
Nick V
Nick Valmost 7 years ago
Any ideas for auto generating final snapshot names? We have some temporary databases we setup and routinely recreate and it'd be nice to automatically give them unique final snapshot names. Currently we just use the creation date and ignore changes but it makes the names a bit weird (since it has creation date in the snapshot for when it was destroyed)
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)almost 7 years ago
that was fast
vitaly.markov
vitaly.markovalmost 7 years ago
yeah, they updated a lot of tools
vitaly.markov
vitaly.markovalmost 7 years ago
I noticed that EKS API does not allow to set min_size into 0, must be at least 1, but can be configured by ASG directly and then EKS API will pull ASG settings and min_size will be 0
vitaly.markov
vitaly.markovalmost 7 years ago
I a little bit played with autoscaler (configured by EKS ng) and this feature https://github.com/kubernetes/autoscaler/tree/master/cluster-autoscaler/cloudprovider/aws#scaling-a-node-group-to-0 doesn’t work
tweetyix
tweetyixalmost 7 years ago
How do you usually "hide" or use encrypted, temporary passwords for terraform resources like RDS? It shouldn't be committed to any repo but somehow available and in code.
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 7 years ago
if password is not provided in a var, generate a random one
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 7 years ago
so the users and apps can read it when needed (using chamber for example)
curious deviant
curious deviantalmost 7 years ago
We use SSM too to store our passwords and random_string resource to generate it in terraform
aaratn
aaratnalmost 7 years ago
Hey ! I just open-sourced terraform and terragrunt version manager.
Please feel free to try it here. PRs are welcome !
https://github.com/aaratn/terraenv
nutellinoit
nutellinoitalmost 7 years ago
nice!
PePe Amengual
PePe Amengualalmost 7 years ago
Anyone with experience in Aurora RDS Global cluster and Terraform ?
Omer Sen
Omer Senalmost 7 years ago
Hello do you guys can suggest a tool to watch terraform state drifts for AWS
jedineeper
jedineeperalmost 7 years ago
any reason not to just use terraform itself?
Omer Sen
Omer Senalmost 7 years ago
I mean i want something automated
Omer Sen
Omer Senalmost 7 years ago
So i have different terraforms on different github so what i want is that if there is anything changed i want to be notified via slack/email etc
Omer Sen
Omer Senalmost 7 years ago
I can do it with a Jenkis job
Omer Sen
Omer Senalmost 7 years ago
But wanted to know if anything else or maybe open sourcr project
Szymon
Szymonalmost 7 years ago
Hi everyone, I have a problem with coalesce function. My TF version is v0.12.16

My code looks like this:

resource "azurerm_app_service_plan" "main" {
  count               = var.plan.id == "" ? 1 : 0
  name                = coalesce(local.plan.name, local.default_plan_name)
  location            = data.azurerm_resource_group.main.location
  resource_group_name = data.azurerm_resource_group.main.name
  ...
}

resource "azurerm_app_service" "main" {
  name                = var.name
  app_service_plan_id = coalesce(var.plan.id, azurerm_app_service_plan.main[0].id)
  ...
}


Error:

Error: Invalid index

  on .terraform/modules/web_container/innovationnorway-terraform-azurerm-web-app-container-ee1e8d4/main.tf line 27, in resource "azurerm_app_service" "main":
  27:   app_service_plan_id = coalesce(var.plan.id, azurerm_app_service_plan.main[0].id)
    |----------------
    | azurerm_app_service_plan.main is empty tuple

The given key does not identify an element in this collection value.


I'm sure that var.plan.id is a valid string, so why coalesce is throwing an error here?
Brij S
Brij Salmost 7 years ago
when creating modules, how do you all handle the fact that the module can be used in the same region/account to create the same resources? (ie; resource name collisions etc)
Brij S
Brij Salmost 7 years ago
for example, if the module creates a codebuild job with the name set as

resource "aws_codebuild_project" "build" {
  name         = "${var.repo}-build"
......

if this module was run twice for the same 'repo' then there would be a collision in names
Brij S
Brij Salmost 7 years ago
how do you all get around this?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 7 years ago
by using naming convention to generate consistent and unique names/IDs for ALL resources
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 7 years ago
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 7 years ago
so the names of your build project would be (for diff environments):
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 7 years ago
mycomp-prod-myapp-build
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 7 years ago
mycomp-dev-myapp-build
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 7 years ago
mycomp-staging-myapp-build
Brij S
Brij Salmost 7 years ago
and if you wanted to have multiple in the dev account for example you could just use the attritubutes to add a 1 or something?
Brij S
Brij Salmost 7 years ago(edited)
mycomp-dev-myapp-build-1 ?
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 7 years ago
yes
Andriy Knysh (Cloud Posse)
Andriy Knysh (Cloud Posse)almost 7 years ago
add more attributes
vFondevilla
vFondevillaalmost 7 years ago
exactly. that module helped me to craft some custom modules and avoiding naming collisions in IAM 😄
Brij S
Brij Salmost 7 years ago
🙂 implementing it now
Nick V
Nick Valmost 7 years ago(edited)
We just use random string (usually 6-8 characters) and tack it on the end of the resource name, truncating the name if the total length would be too long (like elasticache with 20 char limit). It makes it easier to do create before destroy types ops as well (the names end up looking similar to cloudformation generated ones)
TBeijen
TBeijenalmost 7 years ago
What would be needed to move this PR forward? https://github.com/cloudposse/terraform-aws-vpc-peering/pull/16
C
Cloud Possealmost 7 years ago
:zoom: Join us for "Office Hours" every Wednesday 11:30AM (PST, GMT-7) via Zoom.

This is an opportunity to ask us questions on terraform and get to know others in the community on a more personal level. Next one is Dec 04, 2019 11:30AM.

👉️ Register for Webinar

:slack: #office-hours (our channel)
Phuc
Phucalmost 7 years ago
Hi Guys, is there anyway i can use terraform at 1 step in my CI/CD flow to take a snapshot of specific ebs volume ?
Maxim Tishchenko
Maxim Tishchenkoalmost 7 years ago
terraform is not AWS CLI you can do it via aws create-snapshot --volume-id <value>
Maxim Tishchenko
Maxim Tishchenkoalmost 7 years ago(edited)
if you need it in TF

resource "null_resource" "create_snapshot" {
  provisioner "local-exec" {
    command = "aws create-snapshot --volume-id <value>"
  }
}
Maxim Tishchenko
Maxim Tishchenkoalmost 7 years ago
@Phuc ^
automationtrainee
automationtraineealmost 7 years ago(edited)
Does anyone in here use Terraform on GCP by chance?
ismail
ismailalmost 7 years ago
Hey team ,
I was using https://github.com/cloudposse/terraform-aws-vpc-peering.git and got this error.


Error: Missing resource instance key

  on ../modules/vpc-peering/main.tf line 46, in data "aws_subnet_ids" "requestor":
  46:   vpc_id = "${data.aws_vpc.requestor.id}"

Because data.aws_vpc.requestor has "count" set, its attributes must be
accessed on specific instances.

For example, to correlate with indices of a referring resource, use:
    data.aws_vpc.requestor[count.index]

Along with some warnings:

Warning: Quoted type constraints are deprecated

  on ../modules/vpc-peering/variables.tf line 73, in variable "tags":
  73:   type        = "map"

Terraform 0.11 and earlier required type constraints to be given in quotes,
but that form is now deprecated and will be removed in a future version of
Terraform. To silence this warning, remove the quotes around "map" and write
map(string) instead to explicitly indicate that the map elements are strings.


Warning: Interpolation-only expressions are deprecated

  on .terraform/modules/vpc_peering_mgmt_prod.label/main.tf line 2, in resource "null_resource" "default":
   2:   count = "${var.enabled == "true" ? 1 : 0}"

Terraform 0.11 and earlier required all non-constant expressions to be
provided via interpolation syntax, but this pattern is now deprecated. To
silence this warning, remove the "${ sequence from the start and the }"
sequence from the end of this expression, leaving just the inner expression.

Template interpolation syntax is still used to construct strings from
expressions when the template includes multiple interpolation sequences or a
mixture of literal strings and interpolations. This deprecation applies only
to templates that consist entirely of a single interpolation sequence.


Warning: Quoted type constraints are deprecated

  on .terraform/modules/vpc_peering_mgmt_prod.label/variables.tf line 19, in variable "delimiter":
  19:   type        = "string"

Terraform 0.11 and earlier required type constraints to be given in quotes,
but that form is now deprecated and will be removed in a future version of
Terraform. To silence this warning, remove the quotes around "string".


Warning: Quoted type constraints are deprecated

  on .terraform/modules/vpc_peering_mgmt_prod.label/variables.tf line 25, in variable "attributes":
  25:   type        = "list"

Terraform 0.11 and earlier required type constraints to be given in quotes,
but that form is now deprecated and will be removed in a future version of
Terraform. To silence this warning, remove the quotes around "list" and write
list(string) instead to explicitly indicate that the list elements are
strings.


Warning: Quoted type constraints are deprecated

  on .terraform/modules/vpc_peering_mgmt_prod.label/variables.tf line 31, in variable "tags":
  31:   type        = "map"

Terraform 0.11 and earlier required type constraints to be given in quotes,
but that form is now deprecated and will be removed in a future version of
Terraform. To silence this warning, remove the quotes around "map" and write
map(string) instead to explicitly indicate that the map elements are strings.


Can you please check?
Bruce
Brucealmost 7 years ago
Hey guys I am looking to import an existing RDS instance and would like to use the RDS module as well. Has anyone done this? Or have they only bused this module for brand new infrastructure?
jedineeper
jedineeperalmost 7 years ago
i've used import a few times, its a bit finicky but does generally work, the problems you will have are a.) matching config/structure to the module (eg: does it have a parameter group, does that group have the right name format, if not, tf will try to rebuild despite the import) and b.) finding the correct AWS identifier to use for the import. DB resources are generally ARN which should be easy enough
Bruce
Brucealmost 7 years ago
Thanks @jedineeper I will keep that in mind 👍️
jedineeper
jedineeperalmost 7 years ago
i don't know if it'll help you, but it helped me to deploy a standalone copy of the database module, snag the state file then tear it down. With the statefile I could find the right reference format to look for to get the correct IDs for the import command
Bruce
Brucealmost 7 years ago
That's what I've done so far and doing a TF plan shows no uodate, which is a good sign. Although I haven't imported the parameter group, I just referenced the existing one. I am going to try and import this also, as well as the existing security group and Route53 entry.
Brij S
Brij Salmost 7 years ago
has anyone tried/succeeded with using github actions and private terraform modules stored in github? Just tried to set it up yesterday and of course ran into the following error
Error: Failed to download module

Could not download module "domain" (<http://main.tf:45|main.tf:45>) source code
from "git@github.com:org/terraform-aws-domain.git": error
downloading '<ssh://git>@github.com/org/terraform-aws-domain.git':
/usr/bin/git exited with 128: Cloning into
'.terraform/modules/domain'...
Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.



Error: Failed to download module
Vincent Fiset
Vincent Fisetalmost 7 years ago(edited)
EDIT: RESOLVED

👋 I have a helm_release that goes like this:

variable "default_firewall_source_ranges" {
  type        = list
  default = ["10.0.0.0/8", "10.0.0.2/32", "10.0.0.1/32"]
}

resource "helm_release" "haproxy-mysql" {
  name  = "haproxy-mysql"
  chart = "${path.module}/charts/haproxy-mysql"
  namespace = "default"
  values = [
     "${file("${path.module}/charts/haproxy-mysql/values.yaml")}"
  ]
  set {
    name  = "service.loadBalancerIP"
    value = google_compute_address.haproxy_mysql.address
  }
  set {
    name  = "service.loadBalancerSourceRanges"
    value = "{${join(",", var.default_firewall_source_ranges)}}"
  }

  depends_on = [google_container_cluster.gke-cluster]
}

I get this on when I apply:

Error: rpc error: code = Unknown desc = release haproxy-mysql failed: Service "haproxy-mysql" is invalid: spec.LoadBalancerSourceRanges: Invalid value: "[10.0.0.0/8 10.0.0.2/32 10.0.0.1/32]": must be a list of IP ranges. For example, 10.240.0.0/24,10.250.0.0/24

The weird thing is that use the exact same set block in another helm_release without any problem
set {
  name  = "service.loadBalancerSourceRanges"
  value = "{${join(",", var.default_firewall_source_ranges)}}"
}

What is going on here? 🙏
Ryan Ryke
Ryan Rykealmost 7 years ago
hi everyone. wondering if you know of a solid ecs spot fleet module