#terraform - August 2020

August 2020
kskewes
kskewesover 6 years ago
Hey everyone, have been using this module: https://github.com/cloudposse/terraform-aws-rds-cluster - and didn't get around to sorting out our upgrade strategy 🤦
Now looking to update our minor version via engine_version variable. Changing this and doing a plan shows:
1. rds_cluster to be updated in place.
2. rds_cluster_instance to be recreated << downtime event I guess (RDS instances can take many minutes to be created).
Thoughts and questions:
1. apply_immediately variable is set to true (default). We could change.
2. INLINECODE_2 - for instances defaults to true, we would want to change (add to module) if managing version in TF
3. I guess ZDP (Zero Downtime Patching) isn't available via Terraform? Or might happen if we do disable immediately and let update during maintenance window?
4. We could use -target=cluster|instance[0-2] to limit the actions a plan does but this means babysitting the upgrade and could result in downtime if we did an apply without -target flag
5. How are others doing this?
Brice Zakra
Brice Zakraover 6 years ago
Hello everyone,
I am working on a multi availability zones terraform template on aws. I am fairly new to terraform. Can anyone help me with it please? Any advice or sample template to start with my project?
Matt Gowie
Matt Gowieover 6 years ago
Anyone using AWS SSO and configuring it via Terraform? I don’t believe there are resources to do so from a quick google search, but just want to confirm. Really dig AWS SSO, but suggesting it to a client without having Terraform support is making me hesitant as I’m trying to get everything for them onto IaC.
Michał Czeraszkiewicz
Michał Czeraszkiewiczabout 6 years ago
Does anyone know what properties I can use in aws_cloudwatch_event_target.input when used with ECS target? I'm trying to get "PropagateTags": "TASK_DEFINITION" to work. The example shows only the usage of containerOverrides .
Briet Sparks
Briet Sparksabout 6 years ago(edited)
Hi, facing an issue with dynamic values in CodeDeploy appspec.

With CodeBuild, you can set environment variables from Terraform:
resource "aws_codebuild_project" "myapp" {
  // ...
  environment_variable {
    name = "MY_VARIABLE"
    value = var.my_variable
  }
  // ...
}

Which you can conveniently reference in a buildspec.yml
phases:
  commands: 
    - echo $MY_VARIABLE

However with CodeDeploy, you can't environment variables from Terraform, or at least, I have not found such an argument in the codedeploy_app, codedeploy_deployment_config, and codedeploy_deployment_group resources.

So, I'm having to manually sync values between my TF file and appspec.yml. For example, I'm using ECS, so appspec.yml wants:
• TaskDefinition*
• ContainerName*
• Port*
• PlatformVersion
• NetworkConfiguration: { Subnets, SecurityGroups, AssignPublicIp }
These are either TF variables or generated at TF runtime. It would be great if I could inject them into the appspec / CodeDeploy runtime environment and reference them as variables, but again it doesn't seem possible. What might be good workaround?
Vincent Fiset
Vincent Fisetabout 6 years ago(edited)
Hi! I am using terraform .12 with workspaces and modules and everything WAS fine. I had prod and qa as workspaces mainly for “namespacing” in the state and to use as variable around the code. Everything WAS fine because I had the exact same components with light variations that could easily be configured in their respective .tfvar files.

Now I need to add a new prod environment in europe and it won’t have the all the things deployed over there so my setup is kinda screwed 🤦

I was thinking moving to a structure such as:
.
├── environments
│   ├── prod
│   │   ├── america
│   │   │   ├── main.tf
│   │   │   └── prod-america.tfvars
│   │   └── europe
│   │       ├── main.tf
│   │       └── prod-europe.tfvars
│   ├── qa
│   │   ├── main.tf
│   │   └── qa.tfvars
│   └── staging
│       ├── america
│       │   ├── main.tf
│       │   └── staging-america.tfvars
│       └── europe
│           ├── main.tf
│           └── staging-europe.tfvars
└── modules
    ├── dns
    │   └── main.tf
    ├── gcp
    │   ├── gke.tf
    │   ├── main.tf
    │   └── network.tf
    └── releases
        ├── product-a-infra
        │   └── main.tf
        ├── product-b-infra
        │   └── main.tf
        └── shared-infra
            └── main.tf

This would allow me to reference the modules I want in my various environments main.tf…

What would you guys do in this case ?

Also, not sure the workspaces still make sense since each environments main.tf will need to define their own terraform config block thus will separate tfstate in there
Alan Kis
Alan Kisabout 6 years ago(edited)
Terraform gurus 🙂

Using locals and built-in string functions in Terraform, is it possible to change or alter the label name not the value?

task_logging = [
    for k, v in var.task_logging_options : {
      name = trimprefix(k,"TASK_LOGGING_")
      value = v
    }
  ]

So I can do the following in the module instantiation:

task_logging_options = {
    TASK_LOGGING_Name = "es"
    // TASK_LOGGING_Host 
  }

Which is backed by task definition in the module:

task_logging_options = {
    TASK_LOGGING_Name = "es"
    // TASK_LOGGING_Host 
  }

So basically, strip the prefix from each argument to build a logging options object to pass down to the ECS task?
Brij S
Brij Sabout 6 years ago
has anyone created an EKS cluster using Terraform Cloud. How does one retrieve the kubeconfig file?
Paul Nicholson
Paul Nicholsonabout 6 years ago
Hey folks, has anyone come across a tool like scenery that supports terraform 0.12+? I'm more interested in cleaning up the output to obtain just the diff..
Chris Fowles
Chris Fowlesabout 6 years ago
| grep '#' 😛
Chris Fowles
Chris Fowlesabout 6 years ago
terraform 0.12 can output plans to json natively
Patrick Joyce
Patrick Joyceabout 6 years ago
Oh yea, disregard outdated npm 😆
Patrick Joyce
Patrick Joyceabout 6 years ago
terraform show -json <PLAN FILE>
ayr-ton
ayr-tonabout 6 years ago
Hey, how are you doing?
I’m using cloudposse/eks-cluster/aws version 0.24.0 and I’m always experiencing the issue:
Error: configmaps "aws-auth" already exists

  on .terraform/modules/eks_cluster/terraform-aws-eks-cluster-0.24.0/auth.tf line 84, in resource "kubernetes_config_map" "aws_auth_ignore_changes":
  84: resource "kubernetes_config_map" "aws_auth_ignore_changes" {

Does someone already experienced this config map issue?
JMC
JMCabout 6 years ago
I'm running EKS 1.17 right now, and when I use terraform destroy to get rid of a kubernetes_deployment, the replicaset is not deleted in cascade and the pods stays. Anyone else experienced this ?
Mr.Devops
Mr.Devopsabout 6 years ago
Is there a tf module for aws workspaces in the cloudposse repo? I was not able to find any examples
Patrick Joyce
Patrick Joyceabout 6 years ago(edited)
There's still some features lacking in the terraform aws provider to probably make a full IaC module, but you could certainly handle the directory and creation of them like a list of users to create them
Patrick Joyce
Patrick Joyceabout 6 years ago(edited)
The module could handle creation of vpc, subnets etc, workspace directory and users
Mr.Devops
Mr.Devopsabout 6 years ago
I see thx for the info.
Patrick Joyce
Patrick Joyceabout 6 years ago
Yea there's some issue tickets in the aws provider tracking new and upcoming workspace features
Patrick Joyce
Patrick Joyceabout 6 years ago
I think there's a lack of aws api calls to so without those there's nothing the provider can do
Patrick Joyce
Patrick Joyceabout 6 years ago
No apis for creating bundles
rajeshb
rajeshbabout 6 years ago
Does anyone manage to view terraform docs for AWS PROVIDER -- staying blank forever
https://registry.terraform.io/providers/hashicorp/aws/latest/docs
cabrinha
cabrinhaabout 6 years ago(edited)
hey all, just a general Terraform question: I have an EC2 instance that I need to add some userdata to. I want to put a file on the node and run a command. The file is a CA cert:
Error: Invalid expression

  on main.tf line 35, in module "eks":
  35:     pre_userdata = << EOF

Expected the start of an expression, but found an invalid expression token.
sheldonh
sheldonhabout 6 years ago
I am using terraform to create and manage most of my teams repos.

• I want to configure all the managed repos to have a hook integration with Microsoft Teams so Pull notifications come through, anyone done this?
• The branch protection policy is empty. I want to set it to enforce branch protection policy IF anything is placed in the branch hooks. Is that possible or is this just something I’ m going to have to do manually after creation of the repo?
PR follow-ups are a pain to configure in teams with GitHub so was hoping for a simple way to integrate 🙂
Craig Dunford
Craig Dunfordabout 6 years ago
Any one have experience implementing Azure resource locks in tandem with terraform (ie https://www.terraform.io/docs/providers/azurerm/r/management_lock.html). Specifically I am wondering how folks deal with cases when terraform wants to recreate resources.
Jaeson
Jaesonabout 6 years ago
Is anyone using TF to build auto-scaling groups with capacity-optimized spot instances? I'm not finding a good resource that demonstrates how this can be done.
rajeshb
rajeshbabout 6 years ago(edited)
Error: error using credentials to get account ID: error calling sts:GetCallerIdentity: RequestError: send request failed caused by: Post <https://sts.amazonaws.com/>: dial tcp: lookup <http://sts.amazonaws.com|sts.amazonaws.com> on 10.x.x.x:x: write udp 172.31.176.x:54764 >10.x.x.x:53: write: no buffer space available
Does anyone know the cause please
Jaeson
Jaesonabout 6 years ago
Using TF 12, I'd like to define a block for tags that I reuse everywhere, but I'm having a little trouble figuring out how to do this in a way that doesn't feel hacky.
Jaeson
Jaesonabout 6 years ago
Has anyone seen this kind of thing before?
on main.tf line 168, in resource "aws_security_group" "lb_adv2_sg":

168: tags = locals.tags


A managed resource "locals" "tags" has not been declared in the root module.

locals {
  tags = {
    env         = var.environment
    owner       = "DevOps"
    product     = "adv2.0"
    managed_by  = "terraform"
  }
}

is defined above (before) the aws_security_group resource in the same file.
Jaeson
Jaesonabout 6 years ago(edited)
This is when running terraform validate for TF 12. ... Ah. I think I added an 's' to local.
RB
RBabout 6 years ago
why did they even do that
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)about 6 years ago
raghu
raghuabout 6 years ago
Is there a way we can destroy specific resource from a workspace in terraform enterprise? when i comment out the block of code, it says block of code missing.
Tom Howarth
Tom Howarthabout 6 years ago
You will need to use either terraform taint and point it and the requisite resource this will mark it for replacement or terraform destroy and again mark the relevant resource. Use terraform state list to find the correct name of the resource in your state file for deletion of replacement
Eric Berg
Eric Bergabout 6 years ago
I am using the kubernetes provider's kubernetes_namespace resource, successfully, but I'm trying to get the LB URL, which the docs for kubernetes_namespace say should output self_url, but I get this error, when I try to use it:
Error: Unsupported attribute

  on ../../../../../application-stack/helm.tf line 19, in output "k-ns-url2":
  19:   value = kubernetes_namespace.borrower[0].self_url

This object has no argument, nested block, or exported attribute named
"self_url".

Instead, we're using a data.kubernetes_service to pull out the elb name, to use that to create R53 CNAMEs. This results in never having a clean plan, because data.kubernetes_service.nginx-ingress has to be read and resource.aws_lb_ssl_negotiation_policy has a dependency to it for the id.

How do i get the ELB from helm.helm_release for nginx-ingress, maybe?

Thanks for any ideas.
Almog Cohen
Almog Cohenabout 6 years ago
Hi there! I'm trying to use https://github.com/cloudposse/terraform-aws-cicd and the README example seems really outdated. So much that it becomes a pain to try and use the project out-of-the-box.

The example:
1.  says app but it should be elastic_beanstalk_application_name
2. says env but it should be elastic_beanstalk_environment_name
3. says aws_region but should be region
Not sure if there are any other misses, but maybe it would be nice that someone who knows the project can revise this
Juan Soto
Juan Sotoabout 6 years ago
Hi guys, I am very newbie to terraform, I need your help.
I have been asked to conduct an audit and tighten a considerable list of IAM Roles. The problem is as follows:
The previous DevOps guys manually added the AmazonEC2RoleforSSM policy to the IAM Roles (it’s not written the change in TF).
SOC Auditors consider that AmazonEC2RoleforSSM is too wide open, and it needs to be replaced by the following managed policies instead: SSMMaintenanceWindowRole and SSMManagedInstanceCore.
I don’t want to do this task manually, I would like to automate using terraform. Could you please give me some guidance on how to proceed?
I already have the IAM roles list in locals { roles_list=list(role1,role2, role3) }, but I would like to:
1 - Check if AmazonEC2RoleforSSM exists in that role.
2 - If the policy exists, remove it and add SSMManagedInstanceCore and SSMMaintenanceWindowRole
3 - If AmazonEC2RoleforSSM doesn’t exist, add SSMManagedInstanceCore and SSMMaintenanceWindowRole
I am not quite sure how to deal with loops. Thanks!
Patrick Joyce
Patrick Joyceabout 6 years ago
err the terraform aws docs seem to be down https://registry.terraform.io/providers/hashicorp/aws/latest/docs 😞
Patrick Joyce
Patrick Joyceabout 6 years ago
well technically they aren't down, just a lot harder to read
MattyB
MattyBabout 6 years ago
that's a paddlin
rss
rssabout 6 years ago(edited)
v0.13.0
0.13.0 (August 10, 2020)

This is a list of changes relative to Terraform v0.12.29. To see the
incremental changelogs for the v0.13.0 prereleases, see
the v0.13.0-rc1 changelog.

This section contains details about various changes in the v0.13 major release. If you are upgrading from Terraform v0.12, we recommend first referring to <a href="https://www.terraform.io/upgrade-guides/0-13.html"; rel="nofollow">the...
Patrick Joyce
Patrick Joyceabout 6 years ago
think ill give that a few weeks, kind of hard to roll back as terraform upgrades pollute your remote state
Phuc
Phucabout 6 years ago(edited)
Hi guys, I have a use case like this.
I want create a module to receive a custom variable as type “list”
EX:
modules "example" {
services =  [ "a", "b", "c"]
.
.
.
}

As after that variable is input, matching resource for each element in the list will be created

Ex: if the list contains matching [“a”, “b”] then only matching resource “a”, “b” is created.
If the list is empty, then no resource created additionally
then the matching code will trigger up local value as I define

locals {
`` I need to know if local can loop on the list services and pick up each element and assign the value matching

a = if "a" exist then local.a = 1 or if not there no matching element a = 0
b = ...
c = ...
}

resource "aws_resoure_type" "service a" {
count = local.a 
.
.
.
}
resource "aws_resoure_type" "service b" {
count = local.b 
.
.
.
}

I know terraform is powerful but I need to ask you guys if that logic can be done. Thanks a lot
David J. M. Karlsen
David J. M. Karlsenabout 6 years ago
rss
rssabout 6 years ago(edited)
Terraform Cloud Outage
Aug 11, 18:40 UTC
Investigating - We are currently experiencing issues with Terraform Cloud. The UI is down and terraform runs and plans will not complete at this time. We are investigating the issue.
RB
RBabout 6 years ago
how many outages has it been this year?
RB
RBabout 6 years ago
6 outages since june 1
PePe Amengual
PePe Amengualabout 6 years ago
I swear I’m not a contractor for hashicorp
PePe Amengual
PePe Amengualabout 6 years ago
Hello, I’m using https://github.com/cloudposse/terraform-aws-dynamic-subnets and I set enabled = false and I’m getting this error
Error: Error in function call

  on .terraform/modules/haystack.dynamic_subnets/nat-gateway.tf line 42, in resource "aws_nat_gateway" "default":
  42:   subnet_id     = element(aws_subnet.public.*.id, count.index)
    |----------------
    | aws_subnet.public is empty tuple
    | count.index is 0

Call to function "element" failed: cannot use element function with an empty
list.

I think someone else had this issues before?
rss
rssabout 6 years ago
Terraform Cloud Outage
Aug 11, 18:48 UTC
Monitoring - We have identified the issue and plans and applies are currently succeeding, the UI is back up. We are continuing to monitor.Aug 11, 18:40 UTC
Investigating - We are currently experiencing issues with Terraform Cloud. The UI is down and terraform runs and plans will not complete at this time. We are investigating the issue.
rss
rssabout 6 years ago
Terraform Cloud Outage
Aug 11, 19:05 UTC
Resolved - Terraform Cloud is operational again. If a run failed during this outage, please re-queue it. If you have problems queueing runs, please reach out to support.Aug 11, 18:48 UTC
Monitoring - We have identified the issue and plans and applies are currently succeeding, the UI is back up. We are continuing to monitor.Aug 11, 18:40 UTC
Investigating - We are currently experiencing issues with Terraform Cloud. The UI is down and terraform runs and plans will not complete...
Rhawnk
Rhawnkabout 6 years ago
Hi All, got sort of an opinion question here. Does anyone have a preference on using remote state for looking up resources, or using data sources to look them up at runtime? Been trying to research, and not having much luck finding which is recommended or preferred
PePe Amengual
PePe Amengualabout 6 years ago
Hi, anyone have successfully used https://github.com/cloudposse/terraform-aws-ecs-alb-service-task with ECS+EC2 autoscaling and capacity providers?
rss
rssabout 6 years ago(edited)
Problems setting workspace execution mode in Terraform Cloud
Aug 12, 10:35 UTC
Investigating - We are currently investigating an issue where customers may be unable to set workspace execution mode in Terraform Cloud via the web interface. The API for this feature is still functional and can be used while we investigate. Please contact the support team if you need further assistance with this feature.
Josh Duffney
Josh Duffneyabout 6 years ago
How does one create an Azure Service Principal with sdk auth?
rss
rssabout 6 years ago(edited)
Problems setting workspace execution mode in Terraform Cloud
Aug 12, 14:42 UTC
Resolved - We have deployed a fix for this issue. Customers should now be able to set workspace execution modes successfully in the web interface as well as via the API.Aug 12, 10:35 UTC
Investigating - We are currently investigating an issue where customers may be unable to set workspace execution mode in Terraform Cloud via the web interface. The API for this feature is still functional and can be used while we investigate. Please contact the support team if you need...
Matt Gowie
Matt Gowieabout 6 years ago
Hey for folks using the CP key-pair module (https://github.com/cloudposse/terraform-aws-key-pair) — How do you manage not checking that the pem file into git? Removing the pem file from the location the module writes it to obviously causes the module to want to recreate that file which I don’t want. Any tips to deal with that?
Eric Berg
Eric Bergabout 6 years ago(edited)
How do i slice a map, given an array of keys? I have a map containing monitor definitions, but i only need some of them for each invocation of the module. I pass in the keys to the monitor defs that I want, but I have not been able to create a map slice, containing just the keys that were passed in.

So, it looks something like this, where log_errors_high_volume and oom are keys that get passed in.:
locals {
  monitor_defs = {
    log_errors_high_volume = {
      type       = "log alert",
      recipients = local.recipients,
      query      = "....
    },
    oom = {
      type       = "log alert",
      recipients = local.recipients,
      query      = "....

If i only passed in oom, i'd need a map with one element. I intend to use the resulting map as the target for a for_each.
sheldonh
sheldonhabout 6 years ago
Terraform Cloud Plan creates 3 IAM Service Account Users & set the permissions inline for a group called “infra-service-accounts”…..

Would you:
• One Workspace Per Account/Stage: Create a workspace, ie separate terraform job in the cloud, for each account so each runs independently and looks up the credentials based on a variable called “account_alias”.
• One Single Plan With Aliased Providers: Create a single plan that uses aliased providers and just repeat the code/module call, credential lookup, and all 8 times in a single file.
I’ve tended to keep things separate, so each plan and successful failure reports back, but wondering if the provider alias all in one plan is more common. Less workspaces to review as well.
PePe Amengual
PePe Amengualabout 6 years ago
Hello, I have terraform repo that is going beyond any usefulness and I need to separate in different repos and hopefully different state files, what would be the best way to import the resources to the new states? by manually doing terraform import or something else?
Chris Fowles
Chris Fowlesabout 6 years ago
you can move resources between state files
Chris Fowles
Chris Fowlesabout 6 years ago
terraform state mv -state-out=PATH
Path to the destination state file to write to. If this
isn't specified, the source state file will be used. This
can be a new or existing path
Chris Fowles
Chris Fowlesabout 6 years ago
best to lock and disconnect your remote state before undertaking this task
PePe Amengual
PePe Amengualabout 6 years ago
Ok so I will have to go from S3 to local and then back in another S3 backed I guess
PePe Amengual
PePe Amengualabout 6 years ago
Ahhh but I need to move/import certain resources
Chris Fowles
Chris Fowlesabout 6 years ago
Usage: terraform state mv [options] SOURCE DESTINATION

 This command will move an item matched by the address given to the
 destination address. This command can also move to a destination address
 in a completely different state file.

 This can be used for simple resource renaming, moving items to and from
 a module, moving entire modules, and more. And because this command can also
 move data to a completely new state, it can also be used for refactoring
 one configuration into multiple separately managed Terraform configurations.

 This command will output a backup copy of the state prior to saving any
 changes. The backup cannot be disabled. Due to the destructive nature
 of this command, backups are required.

 If you're moving an item to a different state file, a backup will be created
 for each state file.
PePe Amengual
PePe Amengualabout 6 years ago
ahhhhhhhh cool
PePe Amengual
PePe Amengualabout 6 years ago
ok awesome , thanks
Chris Fowles
Chris Fowlesabout 6 years ago
👍️
RB
RBabout 6 years ago
That's pretty cool. I didn't know this. I wonder if you can simply provide the same s3 key argument in the s3 backend from another module. I also wonder how this works with workspaces
Zach
Zachabout 6 years ago(edited)
We’re a little paranoid in my office about giving terraform roles to an external service like Terraform Cloud, or if we had a GitHub Action that ran terraform on some trigger, to the point that we’ve resisted using any of them. … how do you guys scope/limit the role for a terraform ‘actor’ given that its potentially touching a lot of different types of resources and API Actions?
Andy
Andyabout 6 years ago
Hi with this cloudfront S3 module https://github.com/cloudposse/terraform-aws-cloudfront-s3-cdn it recommends creating the ACM certificate using the cli. Why isn't the certificate terraformed? It looks like it's possible: https://github.com/cloudposse/terraform-root-modules/blob/master/aws/acm-cloudfront/main.tf
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)about 6 years ago
i'm working on updating our test infrastructure for 0.13. not much too it if we just want say, "screw it, we're going to 0.13". i'm definitely leaning towards that, but it means that support for 0.12 will be only for hotfixes.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)about 6 years ago
we have hundreds of PRs we gotta open and merge to bump versions everywhere.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)about 6 years ago(edited)
This change will forcefully require 0.13 for merge to master - so I don't want to merge it until we decide how to proceed with 0.12 support.
https://github.com/cloudposse/actions/pull/42/files

GitHub
Use terraform 0.13 by osterman · Pull Request #42 · cloudposse/actions
what Use terraform 0.13 for tests why Latest release
Matt Gowie
Matt Gowieabout 6 years ago
Interesting terraform module generator: https://github.com/sudokar/generator-tf-module

Very similar to the Cloud Posse example module: https://github.com/cloudposse/terraform-example-module
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)about 6 years ago
-- TERRAFORM 0.13 --

Here's my plan for tonight.

1. Push a 0.12/master branch up to all modules, cut from current master
2. Update test automation to use 0.13 for PRs against master
3. Update test automation to use 0.12 for PRs against 0.12/master
During this time, I'm going to change the default branch of cloudposse/actions to my development branch and chatops will likely be broken for a few hours. If I get that working, then I'll merge that and restore the default branch. Then we're set to test the onslaught of PRs. 😃
mm
mmabout 6 years ago
hey all. I'm currently a bit stuck. I've successfully made and provisioned a server, setup s3 buckets etc. How do I then use the docker provider to setup my containers on the newly created server?
mm
mmabout 6 years ago
I tried moving the docker provisioning to a new module, but got this message, and can't work out the syntax :
This module can be made compatible with depends_on by changing it to receive all of its provider configurations from the calling module, by using the "providers" argument in the calling module block.
Saichovsky
Saichovskyabout 6 years ago
Hey guys,
Saichovsky
Saichovskyabout 6 years ago
I have a question regarding TF state as set from different GitHub branches
Saichovsky
Saichovskyabout 6 years ago
Let me explain
Saichovsky
Saichovskyabout 6 years ago
So I am working on a branch, seeking to create a new terraform resource. My branch creates this resource in a staging environment. Once I am done with all tests, then I will merge to merge and allow deployment to production
Saichovsky
Saichovskyabout 6 years ago
My colleague is doing the same thing - a different resource, but deploying to staging, pending tests, upon whose success the resource will then be deployed to production
Saichovsky
Saichovskyabout 6 years ago
So whenever I push my changes to my branch, CI/CD performs checks and deletes my colleagues resources because they are in the shared state file, but absent from my branch
Saichovsky
Saichovskyabout 6 years ago
Same thing happens when he pushes his commits to the remote branch. Checks are triggered on GH, removing my resource(s) which is/are missing from his branch but present in the remote state file. This is really slowing us down as one has to wait for the other to be finished with their testing and so forth. I have a feeling that there should be a way to prevent this from happening, but I am just not sure how
Saichovsky
Saichovskyabout 6 years ago
Your assistance is appreciated
RB
RBabout 6 years ago
what is a safe way to migrate from route table/security group/etc in-line routes/rules to individual routes/rules terraform resources ?

e.g. aws_route routes vs setting all the routes in-line in aws_route_table as there is this warning

Terraform currently provides both a standalone Route resource and a Route Table resource with routes defined in-line. At this time you cannot use a Route Table with in-line routes in conjunction with any Route resources. Doing so will cause a conflict of rule settings and will overwrite rules.
bbhupati
bbhupatiabout 6 years ago
Hello All,
I'm new to the terraform, i'm trying to covert terraform kubernetes ingress resource into module(https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/ingress#backend), but when i'm calling the module getting below error. Can someone help me how to fix it
bbhupati
bbhupatiabout 6 years ago
resource "kubernetes_ingress" "example_ingress" {
  count = var.ingress ? length(var.spec) : 0
  metadata {
    name = var.name
    namespace= var.namespace
    labels   = var.labels
    annotations = var.annotations
  }
  dynamic "spec" {
    for_each = length(keys(var.spec[count.index])) == 0 ? [] : [var.spec[count.index]]
    content {
      rule = lookup(spec.value, "rule", null)
    
    
    dynamic "rule" {
      for_each = length(keys(lookup(spec.value, "rule", {}))) == 0 ? [] : [lookup(spec.value, "rule", {})]
      content {
          host = lookup(rule.value, "host", null)
          http {
            path {
              path = lookup(rule.value, "path", "*/")
              backend {
                service_name = lookup(rule.value, "service_name", null)
                service_port = lookup(rule.value, "service_port", null)
              }
            }
          }
        }
      }
    }
  }
}
bbhupati
bbhupatiabout 6 years ago
Error: Missing item separator

on ingress.tf line 17, in module "ingress":
16:
17: rule = {

Expected a comma to mark the beginning of the next item.

[terragrunt] 2020/08/17 05:22:39 Hit multiple errors:
exit status 1
Andy
Andyabout 6 years ago
Those of you using chamber to store secrets in AWS Parameter Store - do you store the secrets encrypted in a git repository as well as a backup?
Mike Martin
Mike Martinabout 6 years ago(edited)
Hi there - we are looking to import our Route53 hosted zones (that are currently managed by hand) into TF Cloud. The ideal layout (at least the way I see it now) is that we have the following GitHub layout and can be managed by CODEOWNERS to approve specific files. Does it make sense to put it all in one workspace, or should each hosted zone get its own workspace? I know ideally, we’d want each lifecycle to get it’s own workspace, but that isn’t a reality yet as many things are old and spun up by hand and may never exist in terraform.

### main.tf
provider "aws" {
  region     = "us-east-1"
  access_key = KEY
  secret_key = SECRET
}

terraform {
  backend "remote" {
    hostname     = "<http://app.terraform.io|app.terraform.io>"
    organization = "Org"

    workspaces {
      name = "aws-prod-route53"
    }
  }

  # <https://github.com/terraform-providers/terraform-provider-aws/issues/13626>
  required_providers {
    aws = "~> 2.64.0"
  }
}

resource "aws_route53_record" "staging_record" {
  zone_id = aws_route53_zone.org.zone_id
  name    = "<http://staging.org.com|staging.org.com>"
  type    = "A"
  ttl     = 300
  records = ["55.82.222.111"]
}

### network-team.tf
resource "aws_route53_record" "cisco_record" {
  zone_id = aws_route53_zone.org.zone_id
  name    = "<http://cisco.org.com|cisco.org.com>"
  type    = "A"
  ttl     = 300
  records = ["55.82.222.112"]
}

### CODEOWNERS
## <https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners>
*                  @global-owner1 @global-owner2
network-team.tf    @network-owner
sheldonh
sheldonhabout 6 years ago
Anyone get a basic quote on Terraform Business Tier? Trying to figure general price to put a placeholder in the budget, but no phone number to call and not sure how long before I get an email from sales.

Ballpark would be helpful. Team tier $70 per person, and business is “contact sales”
Sheece
Sheeceabout 6 years ago
Hi, I noticed value for module.ssh_key_pair.name capital letter are automatically converted to lowercase!
module "ssh_key_pair" {
  source                = "git::<https://github.com/cloudposse/terraform-aws-key-pair.git?ref=0.11.0>"
  name                  = "KEYPAIR"
  ssh_public_key_path   = "${path.module}/"
  generate_ssh_key      = "true"
  private_key_extension = ".pem"
  public_key_extension  = ".pub"
}

Is this a known thing or am I doing something wrong ?
Wali
Waliabout 6 years ago(edited)
hello all, I'm trying to point a list of records sets to a single load balancer. I've got this tf settup
#---------------------------------------------------
# CREATE ALIAS RECORDS
#---------------------------------------------------
resource "aws_route53_record" "alias_route53_record" {
  zone_id = data.aws_route53_zone.selected.zone_id
  name    = values(var.record_sets)
  type    = "A"

  alias {
    name                   = data.aws_lb.selected.dns_name
    zone_id                = data.aws_lb.selected.zone_id
    evaluate_target_health = true
  }
}

#tfvars
record_sets = {
  record_set0 = "foo"
  record_set1  = "bar"
}

Error output
Error: Incorrect attribute value type

  on main.tf line 39, in resource "aws_route53_record" "alias_route53_record":
  39:   name    = values(merge(var.record_sets))
    |----------------
    | var.record_sets is object with 2 attributes

Inappropriate value for attribute "name": string required.

Was wondering if this is possible or must I create two aws_route53_record resources. Thank you
Wali
Waliabout 6 years ago(edited)
Resolved. Forgot for_each existed 😐️
resource "aws_route53_record" "alias_route53_record" {
  zone_id  = data.aws_route53_zone.selected.zone_id
  for_each = var.record_sets
  name     = each.value
  type     = "A"

  alias {
    name                   = data.aws_lb.selected.dns_name
    zone_id                = data.aws_lb.selected.zone_id
    evaluate_target_health = true
  }
}
rss
rssabout 6 years ago(edited)
Hashicorp Consul Service (HCS) for Azure affected
Aug 18, 15:43 UTC
Resolved - At approximately 14:26UTC we began experiencing errors with the creation of consul clusters for HashiCorp Consul Service (HCS) on Azure.

Engineers quickly identified the issue and implemented corrective action.

Services are now in fully operational.
Andrew Nazarov
Andrew Nazarovabout 6 years ago
I’m facing a strange issue. Cannot figure out what’s happened

We just did some modifications to one resource in our .tf file, nothing else and from that point terraform plan started showing logs as if it were with TF_LOG=TRACE. There is no env var set.

Terraform 0.12.24, it’s a resource of some external provider.
Andy Hibbert
Andy Hibbertabout 6 years ago
Hey! Would I be able to get a review on this PR to add in kms_key_id to terraform-aws-elasticache-redis - https://github.com/cloudposse/terraform-aws-elasticache-redis/pull/75
Vlad Ionescu (he/him)
Vlad Ionescu (he/him)about 6 years ago
https://github.com/aws/containers-roadmap/issues/56 is killing me. Anybody got a better alternative to config files in Fargate, other than a sidecar container&base64?

I was thinking maybe EFS & local-exec to copy a file but that's even worse
joshmyers
joshmyersabout 6 years ago
https://github.com/aliscott/infracost looks interesting, but early days
sahil kamboj
sahil kambojabout 6 years ago
Hey guys i have a work flow with a loophole
in terraform script i use a provision server which make a ami. that ami is used by autoscaing groups.
after that i dont need that provision server , if i force remove it manually it creating a issue like whenever i do terraform apply it recreates that provision server and want to update that ami.
I dont want to do provisioning manually.
Andrew Nazarov
Andrew Nazarovabout 6 years ago
Does anybody know if Terraform has a state file size limit? Is there any recommendations that it shouldn’t be, say, more than nMb?
All I could find is this discussion: https://discuss.hashicorp.com/t/getting-error-when-tfstate-is-larger-than-4mb/6121
Wali
Waliabout 6 years ago(edited)
ello peoples, anyone know of any good resources on implementing ci/cd on aws with terraform. In particular best practices on managing the plan and apply commands in the build phase using codebuild and interacting with s3 state files?
sheldonh
sheldonhabout 6 years ago
Is there any solution to using the Terraform Cloud module repository for my team without everyone needing a login?
I mean, i like the browsing the ability to use version syntax without tags and all, but I realized if I wanted to rollout consuming those, NOT running plans, I’m stuck as 5 free users is hit. I need to basically allow “read-only” users for the registry for example.

Any known solution to this?
Theo Gravity
Theo Gravityabout 6 years ago(edited)
Anyone know how to resolve this issue? https://github.com/cloudposse/terraform-aws-ecs-web-app/issues/63

I'm trying the complete example using EC2 with codepipeline_enabled = false, webhook_enabled=false, ecs_alarms_enabled=false, codepipeline_badge_enabled=false

I get:

Error: If `individual` is false, `organization` is required.

  on .terraform/modules/ecs_web_app.ecs_codepipeline.github_webhooks/main.tf line 7, in provider "github":
   7: provider "github" {

If I define codepipeline_repo_owner= "hashicorp like the issue describes, I get:

Error: If `anonymous` is false, `token` is required.

 on .terraform/modules/ecs_web_app.ecs_codepipeline.github_webhooks/main.tf line 7, in provider "github":
  7: provider "github" {

I looked at the provider "github" definition in the subdep and there does not seem to be a direct way of defining it from this repo
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)about 6 years ago
Set the GITHUB_TOKEN environment variable and try again
Theo Gravity
Theo Gravityabout 6 years ago(edited)
Hm, no go, tried a few ways

• export GITHUB_TOKEN=test
• GITHUB_TOKEN=test terraform apply --var-file=eng.tfvars
• terraform apply --var-file=eng.tfvars -var 'GITHUB_TOKEN=test'
Theo Gravity
Theo Gravityabout 6 years ago
Oh, I noticed I get 401 Bad credentials []
Theo Gravity
Theo Gravityabout 6 years ago
but I don't even want to use anything related to codepipeline
Theo Gravity
Theo Gravityabout 6 years ago(edited)
maybe this module isn't for me - maybe I should use terraform-aws-ecs-alb-service-task instead

thanks for your help, I'm going to use the other module
RB
RBabout 6 years ago(edited)
Just set the repo_owner = "hashicorp" and it should work. It's mentioned in the steps to reproduce.
Mr.Devops
Mr.Devopsabout 6 years ago
hoping someone can help. I created an individual environment module which sources out to my main module.
module "test" {
  source     = "../../terraform-aws-ec2-auto-scale/"
  region     = var.region
  aws_vpc    = var.aws_vpc
  subnet_ids = var.subnet_ids
}

If i execute a plan in my environment module I get the following error
2020/08/20 11:00:57 [ERROR] eval: *terraform.EvalSequence, err: Your query returned no results. Please change your search criteria and try again.
2020/08/20 11:00:58 [WARN] ReferenceTransformer: reference not found: "var.subnet_ids"
module.prtg.data.aws_security_group.default: Refreshing state...
module.prtg.data.aws_subnet_ids.default: Refreshing state...

Error: Your query returned no results. Please change your search criteria and try again.

But if i execute a plan within my source module, terraform plan and apply works.
erik
erikabout 6 years ago
Adrian Navarrete
Adrian Navarreteabout 6 years ago
Hi all, I am using this module https://registry.terraform.io/modules/terraform-aws-modules/atlantis/aws/2.23.0 thanks to @antonbabenko, for setting up Atlantis with Gitlab, it works fine when the the load balancer is external, but as soon as I change it to be internal is not reachable from the internet and therefore from Gitlab servers.
Do you know if this module supports or what I can do for being able to use the internal ALB and being reachable from gitlab servers / the internet ?
Many thanks in advance.
Grid Cell
Grid Cellabout 6 years ago
Hi All, I'm trying to setup a EKS cluster and have the following config on a brand new AWS account. I want the private subnets to use a NAT gateway
module "vpc" {
  source = "git::<https://github.com/cloudposse/terraform-aws-vpc.git?ref=tags/0.16.1>"
  namespace = var.namespace
  stage = var.stage
  name = var.name
  attributes = var.attributes
  cidr_block = "172.16.0.0/16"
  tags = local.tags
  enable_internet_gateway = true
}

module "subnets" {
  source = "git::<https://github.com/cloudposse/terraform-aws-dynamic-subnets.git?ref=tags/0.19.0>"
  availability_zones = var.availability_zones
  namespace = var.namespace
  stage = var.stage
  name = var.name
  attributes = var.attributes
  vpc_id = module.vpc.vpc_id
  igw_id = module.vpc.igw_id
  cidr_block = module.vpc.vpc_cidr_block
  nat_gateway_enabled = true
  nat_instance_enabled = true
  tags = local.tags
  vpc_default_route_table_id = ""

}

module "eks_cluster" {
  source = "git::<https://github.com/cloudposse/terraform-aws-eks-cluster.git?ref=tags/0.24.0>"
  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
  local_exec_interpreter = var.local_exec_interpreter
  oidc_provider_enabled = var.oidc_provider_enabled
  enabled_cluster_log_types = var.enabled_cluster_log_types
  cluster_log_retention_period = var.cluster_log_retention_period
  kubernetes_config_map_ignore_role_changes = false
}

When I apply this there is some weird race condition which results in every time, even if I delete the resources and start again
Error: Error creating route: RouteAlreadyExists: The route identified by 0.0.0.0/0 already exists.
	status code: 400, request id: xxx
  on .terraform/modules/subnets/nat-gateway.tf line 62, in resource "aws_route" "default":
  62: resource "aws_route" "default" {



Error: Error creating route: RouteAlreadyExists: The route identified by 0.0.0.0/0 already exists.
	status code: 400, request id: xxx

  on .terraform/modules/subnets/nat-gateway.tf line 62, in resource "aws_route" "default":
  62: resource "aws_route" "default" {

I only see this error when
 nat_gateway_enabled = true
  nat_instance_enabled = true

in the subnets module. Can someone please help me track why this occurs or help me debug this before I raise it as a bug? 🙏
RB
RBabout 6 years ago
is a .hcl file the same as a .tf file ?
Patrick Joyce
Patrick Joyceabout 6 years ago
They are both HashiCorp configuration language but one uses the specific terraform syntax
Patrick Joyce
Patrick Joyceabout 6 years ago
I know .hcl is used for vault config and policies
RB
RBabout 6 years ago
Psy Shaitanya
Psy Shaitanyaabout 6 years ago(edited)
Hey Guys, I’ve started using EKS cluster terraform module. I was running few tests with the release tag - 0.26.1. I see that there is no kubeconfig path to store on local or the content that is being shown, all i see is the "kubernetes_config_map_id". I’ve seen people using kubeconfig_path = var.kubeconfig_path in the earlier versions. Not sure if i’m missing something or what is the best way to display the contents of kubeconfig from the outputs or storing it on local path.

Thanks for you help in advance.
Andrew Roth
Andrew Rothabout 6 years ago
Chris Fowles
Chris Fowlesabout 6 years ago
https://github.com/minamijoyo/hcledit - a commandline hcl2 attribute editor
Emmanuel Gelati
Emmanuel Gelatiabout 6 years ago(edited)
whic is one of those is better, resouce "foo_resource" "example" {} or resouce foo_resource "example" ?
Chris Fowles
Chris Fowlesabout 6 years ago
i've been going with the policy of quotes only when absolutely necessary
so resource foo_resource example {}
Pierre Humberdroz
Pierre Humberdrozabout 6 years ago
Has some gotten 0.13 working with locally installed providers that are not yet in the terraform registry ?
Brice Zakra
Brice Zakraabout 6 years ago
Hello,
I want to build a bootstrapping for a new SM IaaS process so that I can deploy SM resources in a standardized and repeatable fashion. I need some help and guidance to start my project. Any advice please?
Laurynas
Laurynasabout 6 years ago
Hi, How do I output a resource created with for each?
resource "aws_route53_record" "cloudfront" {

  for_each = toset(var.domain_name)
  name     = each.key
}

output "dns_record" {
  value = aws_route53_record.cloudfront[each.key].fqdn
}

Gives error : 
The "each" object can be used only in "resource" blocks, and only when the
"for_each" argument is set.
Wali
Waliabout 6 years ago
hello peoples - anyone know of any good terraform slack notification tool which shows plan/destroy in slack?
Makeshift (Connor Bell)
Makeshift (Connor Bell)about 6 years ago
Does anybody know if there's a way to force a recreate on an instance when userdata changes? I've found a lot of documentation on people having the opposite problem a few years ago (that it used to do that, but now it doesn't)
MattyB
MattyBabout 6 years ago
https://github.com/cloudposse/terraform-aws-ecs-alb-service-task/commit/19b680d0d21796fa21bf97aef40ebd8f1acc84c4
It looks like this is a breaking change for the way we're using this module which maybe I wasn't using correctly. Why is aws_iam_role.ecs_service disabled when using awsvpc as the network_mode?
btai
btaiabout 6 years ago
seems like region is not a field on the bucket resource anymore? how does it decide which region to provision in? using the provider region?
Jakub
Jakubabout 6 years ago
hello, does anybody knows how to run tests and merge this PR ?
Jakub
Jakubabout 6 years ago
Matt Gowie
Matt Gowieabout 6 years ago
This new, opinionated Terraform wrapper / framework just launched: https://terraspace.cloud/

I wouldn’t use it, but would be interested in hearing from others if they would.
btai
btaiabout 6 years ago
anyone have an example of disabling/enabling replication configuration in an s3 bucket via a flag?

here’s my config for the main bucket that isn’t currently working:
replication_configuration {
    role = aws_iam_role.replication.*.arn
    
    rules {
      status = local.enable_replica_bucket ? "Enabled" : "Disabled"

      destination {
        bucket        = aws_s3_bucket.replica_bucket.*.arn
        storage_class = "STANDARD"
      }
    }
  }

The thing is the resources for the iam role and the replica bucket only exist if enable_replica_bucket is true
Tehmasp Chaudhri
Tehmasp Chaudhriabout 6 years ago
What do folks here do with respect to AWS Subnets and using data lookups to find Subnet IDs to use in other modules - more importantly need a pattern for finding Subnet IDs with free address space and then ensuring future state doesn’t change for already deployed infrastructure? Basically - our network team doesn’t give us alot of network/IP space - so we’ve carved what we do have and created this concept of Subnet Pools across AZs. Issue is how to fan across each Pool while being properly deterministic? I usually don’t have this problem since most places I’ve worked aren’t so stingy w/ IP space in AWS 🙂
Adrian Navarrete
Adrian Navarreteabout 6 years ago
Hi all, I am using this module https://registry.terraform.io/modules/terraform-aws-modules/atlantis/aws/2.23.0 thanks to @antonbabenko,  for setting up Atlantis with Gitlab, it works fine when the the load balancer is external, but as soon as I change it to be internal is not reachable from the internet and therefore from Gitlab servers.
Do you know if this module supports or what I can do for being able to use the internal ALB and being reachable from gitlab servers / the internet ?
Many thanks in advance.
rss
rssabout 6 years ago(edited)
HCS Azure Marketplace Integration Affected
Aug 26, 15:38 UTC
Investigating - We are currently experiencing a potential disruption of service regarding our Azure Marketplace Application offering. Our incident handlers and engineering teams are investigating this matter to provide a timely mitigation of impact.

As our teams work on this issue we will provide further ongoing information as it becomes available. If you have questions or are experiencing difficulties with this service please reach out to our customer support team (Needs...
rss
rssabout 6 years ago(edited)
HCS Azure Marketplace Integration Affected
Aug 26, 16:55 UTC
Update - We have confirmed a disruption of service regarding Azure Marketplace Application integration. Our incident handlers and engineering teams are continuing to address this matter with our Azure partners and hope to provide further updates soon.

As our teams work on this issue we will provide further ongoing information as it becomes available. If you have questions or are experiencing difficulties with this service please reach out to your customer support team....
rss
rssabout 6 years ago
HCS Azure Marketplace Integration Affected
Aug 26, 16:55 UTC
Update - We have confirmed a disruption of service regarding Azure Marketplace Application integration. Our incident handlers and engineering teams are continuing to address this matter with our Azure partners and hope to provide further updates soon.

As our teams work on this issue we will provide further ongoing information as it becomes available. If you have questions or are experiencing difficulties with this service please reach out to your customer support team....
Emmanuel Gelati
Emmanuel Gelatiabout 6 years ago
Hello, I am using terraform with azure and I have an strange issue, I create a cluster with two nodes pools and everything works, but I remove one of the node pool, the cluster get recreated 😞
rss
rssabout 6 years ago(edited)
v0.13.1
0.13.1 (August 26, 2020)
ENHANCEMENTS:
config: cidrsubnet and cidrhost now support address extensions of more than 32 bits (#25517)
cli: The directories that Terraform searches by default for provider plugins can now be symlinks to directories elsewhere. (This applies only to the top-level directory, not to nested directories...
zeid
zeidabout 6 years ago
Anyone work with SSM document using schema 2.x and get an error when associating them with an instance? I get the error

Error creating SSM association: InvalidDocument: Document schema version, 2.2, is not supported by association that is created with instance id
rss
rssabout 6 years ago(edited)
HCS Azure Marketplace Integration Affected
Aug 26, 20:04 UTC
Update - We are continuing to see a disruption of service regarding Azure Marketplace Application integration. Our incident handlers and engineering teams are continuing to address this matter with our Azure partners and hope to provide another update soon.

If you have questions or are experiencing difficulties with this service please reach out to your customer support team.

IMPACT: Updating, creating, or deleting HashiCorp Consul Service on Azure clusters may be delayed...
rss
rssabout 6 years ago
HCS Azure Marketplace Integration Affected
Aug 26, 20:55 UTC
Resolved - Our Azure partners have mitigated the issue and we are seeing recovery from our tests. We are considering this incident resolved. If you see further issues please contact HashiCorp Support.Aug 26, 20:04 UTC
Update - We are continuing to see a disruption of service regarding Azure Marketplace Application integration. Our incident handlers and engineering teams are continuing to address this matter with our Azure partners and hope to provide another update soon.

If...
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)about 6 years ago(edited)
heads up! we've made a some significant improvements to the terraform-null-label module and it's handling of context passing betwen modules. we've introduced a new concept of context.tf which is the standard set of variable inputs for each module. we'll be slowly rolling this out to all our modules. this change 💯 preserves backwards compatibility, but adds the ability to very tersely pass context between our modules. this change was spearheaded by @Jeremy G who updated it.
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)about 6 years ago
@Joe Hosteny we also fixed the issue you raised.
rss
rssabout 6 years ago(edited)
Terraform Cloud scheduled maintenance
THIS IS A SCHEDULED EVENT Aug 30, 07:30 - 08:30 UTCAug 27, 10:28 UTC
Scheduled - We will be undergoing a scheduled maintenance to make some network upgrades to Terraform Cloud. We don't anticipate any customer-facing impact to our services during this window.
Jon
Jonabout 6 years ago
Good morning, I am running into a dynamic grants issue with the S3 module version 0.17.1 and was wondering if anyone had any recommendations. I'm using Terraform v.12.24. I have ACL set to private and do not wish to use grants at this time so it should be defaulting to null.

Error: Unsupported block type

  on .terraform/modules/terraform_s3_bucket/terraform-aws-s3-bucket-0.17.1/main.tf line 92, in resource "aws_s3_bucket" "default":
  92:   dynamic "grant" {

Blocks of type "grant" are not expected here.
Alan Kis
Alan Kisabout 6 years ago
Another neat one:

Terraform versioned modules in AWS CodeCommit with federated access? Has someone had success with it?
Brij S
Brij Sabout 6 years ago
Hey, all! I see in the Terraform documentation they recommend using the provider in the module name, for example terraform-aws-xxxx for a module that contains all aws resources. I’ve got a situation where I’ve technically two providers in a module of mine - helm and aws. Is there guidelines on this? Or do I need to split this up 🤔
Tom Howarth
Tom Howarthabout 6 years ago
this might sound like an odd request, but I am attempting to automatically configure kubectl after deploying an EKS cluster I have captured the generated clustername as a Terraform Ouptut and I want to feed that to kubectl as an input.

I was thinking of using a provisoner local exec to configure kubectl in the script, but I know the using provisioners is frowned upon.
Tom Howarth
Tom Howarthabout 6 years ago
so I was wondering if there was a better way of doing it.
sheldonh
sheldonhabout 6 years ago
anyone regularly using tflint? I’m suprised I hadn’t run across it sooner. I don’t have sentinel right now as on free terraform cloud version. The tflint seems pretty cool to plug-in to my github actions checks and all.
Jon
Jonabout 6 years ago
How can I properly set my own CMK using the dynamodb module version 0.18.0? I see the enable_encryption parameter that I can set to true. That works. I want to specify a kms_key_arn. I see it's normally available through the resource but when I try to add it, it says it's in invalid parameter. When I look at the main.tf in the repo, I see the server_side_encryption block without the ability to add a CMK. I'm wanting to setup Terraform dynamoDB locking so I'd like to use a CMK. Just curious if the module by default creates a separate key, uses a default one, uses the one associated with my S3 bucket or what.. Thank you in advance!
sheldonh
sheldonhabout 6 years ago
Wow. What a setup experience.

Check this out: https://www.gitpod.io/docs/self-hosted/latest/install/install-on-aws-script/

Super smooth docker container that downloaded all the required terraform internally and persisted to local volume when done + asked for input from user. Super impressed
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)about 6 years ago
If anyone is curious how much effort goes into code review for new modules, check this one out! https://github.com/cloudposse/terraform-aws-msk-apache-kafka-cluster/pull/1
zidan
zidanabout 6 years ago
When writing code and you notice that you are taking copy-paste from place to place you will think about DRY “don’t repeat yourself” principle and you will move the shared code to a class of function, so you don’t need to repeat it again and again, but what about if you want to apply the same in terraform? here are some tips that I follow when I write a terraform script, check it out and let me know what do u think?
https://www.dailytask.co/task/tips-that-i-follow-when-i-provision-my-aws-resources-using-terraform-ahmed-zidan
Peter Huynh
Peter Huynhabout 6 years ago
gday everyone. I've got a quick question about the cloudposse module. I am looking to setup a static (restricted access) website, and decided to go down the s3 + cloudfront + ACM + Lambda@edge (for authentication and basic routing). I was wondering if https://github.com/cloudposse/terraform-aws-cloudfront-s3-cdn does a lot of those heavy lifting already?
Peter Huynh
Peter Huynhabout 6 years ago
I've got a question about for_each. What I am trying to do is to create an SSL certificate via ACM. Following the example from hashicorp, https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/acm_certificate_validation, they have DNS validation and have an example resource. However, when grouping all the resources together, I get the (somewhat famous) error: The "for_each" value depends on resource attributes that cannot be determined until apply.
Is there any common practices to get around this issue, or should I just do a terraform apply -target && terraform apply?
Exequiel Barrirero
Exequiel Barrireroabout 6 years ago(edited)
Hey there SweetOps community!!! We appreciate a 👍️ if someone came across this :terraform: tf-0.13.1 :github: issue -> https://github.com/hashicorp/terraform/issues/26038
Your collab would be trully useful 💪 🙏🏻
Thanks in advance! 🙌 🙂
Erik Osterman (Cloud Posse)
Erik Osterman (Cloud Posse)about 6 years ago
We can now accept PRs for 0.13 and test them
erik
erikabout 6 years ago
Van Johnson
Van Johnsonabout 6 years ago
Hoping this is the correct channel. I’m trying to figure out how to get a json object with jsonencode from a list of maps. But I’m not getting the desired outcome. 

What I need the json to be is…
{
   "bob.role":"arn:aws:iam::1234:role/access-role-bob",
   "bob.path":"*",
   "dave.role":"arn:aws:iam::1234:role/access-role-dave",
   "dave.path":"prod/files"
 }

Here’s an example list
locals {
  users = [
    { username : "bob", path : "*" },
    { username : "dave", path : "prod/files" },
  ]

  secret = [
    for index, data in local.users : 
      map(
        "${data["username"]}.role", "arn:aws:iam::1234:role/access-role-${data["username"]}",
        "${data["username"]}.path", "${data["path"]}"
      )
  ]
}

And I get the correct map that I want for each, but it’s still a list(map). I’ve tried merge and few other functions.
$ terraform console
> local.secret
[
  {
    "bob.path" = "*"
    "bob.role" = "arn:aws:iam::1234:role/access-role-bob"
  },
  {
    "dave.path" = "prod/files"
    "dave.role" = "arn:aws:iam::1234:role/access-role-dave"
  },
]
Peter Huynh
Peter Huynhabout 6 years ago
Hello, I have a module that creates an SSL certificate. Now, I am running on a different region to us-east-1 , so I declared 2 provider "aws" and the us-east-1 has an alias.

Things are looking fine until I run terraform plan, and I get this error,
To work with module.docs-site.aws_acm_certificate.ssl its original
provider configuration at
module.docs-site.provider["<http://registry.terraform.io/hashicorp/aws|registry.terraform.io/hashicorp/aws>"].us-east-1
is required, but it has been removed. This occurs when a provider
configuration is removed while objects created by that provider still exist in
the state. Re-add the provider configuration to destroy
module.docs-site.aws_acm_certificate.ssl, after which you can
remove the provider configuration again.

Is there a way for me to pass the provider reference that defined in the global module into the child module?
Peter Huynh
Peter Huynhabout 6 years ago
hey, when I rename the local reference to a module, it destroys the stack previously referenced and build a new one. In this scenario, I am wondering if:
• there is a way for me to migrate the reference to the new name? The resources are the same, just the references in the statefile changes.
• When terraform deletes and creates the same resource (eg an S3 bucket with the same name), it throws an error. Is there a way to nicely handle this situation?
rss
rssabout 6 years ago
Terraform Cloud scheduled maintenance
Aug 30, 08:00 UTC
Completed - The scheduled maintenance has been completed.Aug 30, 07:00 UTC
In progress - Scheduled maintenance is currently in progress. We will provide updates as necessary.Aug 27, 10:28 UTC
Scheduled - We will be undergoing a scheduled maintenance to make some network upgrades to Terraform Cloud. We don't anticipate any customer-facing impact to our services during this window.
james
jamesabout 6 years ago
warning: the combination of terraform cloud + terraform 0.13.0 has completely deadlocked one of our workspaces:
1. one of my team upgraded to terraform 0.13.0, applied a change
2. now nobody can touch that state with 0.12
3. BUT somehow the state has something inside that 0.13.0 doesn’t like:
Error: Invalid resource instance data in state

Instance module.public_api01.aws_instance.instance data could not be decoded
from the state: unsupported attribute "network_interface_id".

4. https://github.com/hashicorp/terraform/issues/25752 - previously the only fix was to manually edit the state back to say 0.12, but manually editing this state file is not possible in terraform cloud (state push with 0.13 will override the terraform version to 0.13, and 0.12 refuses to push)

…but now after writing all this I see that a fix was included in 0.13.1 🎉
james
jamesabout 6 years ago
still, terraform’s handling of upgrades is really obnoxious IMO
james
jamesabout 6 years ago
working in a team, if anyone uses a newer version, everyone is forced to upgrade and there’s often no way back
loren
lorenabout 6 years ago
@james highly recommend a strict pin of the terraform version, to prevent such accidental upgrades... put this in your root config:
terraform {
  required_version = "0.13.1"
}

Peter Huynh
Peter Huynhabout 6 years ago
hello, when writing a composite module for terraform, is it worth split logical components into separate files? My main.tf is growing a bit, and I was wondering if there are best practices around this scenario. Thanks in advanced.
sheldonh
sheldonhabout 6 years ago
I keep having issues on a module I pulled in with the failed to find provider due to the new source path stuff in 0.13. Anyone have a quick fix to this besides the upgrade command as I just need to tear some stuff down but dependent modules

Error while installing hashicorp/template v2.1.2: after installing
<http://registry.terraform.io/hashicorp/template|registry.terraform.io/hashicorp/template> it is still not detected in the target directory; this is a bug in Terraform