Giter VIP home page Giter VIP logo

Comments (10)

osterman avatar osterman commented on June 14, 2024

@jschaul typically we implement this by adding an enabled variable which disables the module. Not all of our modules support this flag.

If you have time to implement this feature, we'll gladly accept the Pull Request.

Someone recently submitted this PR which demonstrates this strategy: cloudposse/terraform-aws-route53-alias#11

We also have a module here that implements it:
https://github.com/cloudposse/terraform-aws-ecs-cloudwatch-sns-alarms/

Please have a look. Also, join our slack team to reach us directly.

https://slack.cloudposse.com

from terraform-aws-cloudfront-s3-cdn.

catdevman avatar catdevman commented on June 14, 2024

@osterman If no one else is going to take this I am willing to take a look at it. If I get it figured out I will put in a PR. Love everything that CloudPosse is doing, especially for the Terraform community!

from terraform-aws-cloudfront-s3-cdn.

osterman avatar osterman commented on June 14, 2024

Thanks @catdevman! That would be awesome. We appreciate your support!

from terraform-aws-cloudfront-s3-cdn.

catdevman avatar catdevman commented on June 14, 2024

@osterman Still learning some of the tips and tricks of Terraform... Having some issues with optional adding the logging_config key for the aws_cloudfront_distribution resource. So I added enabled to terraform-aws-s3-log-storage which is currently in PR, so I have it where it won't the logging s3 bucket.

The expected logging_config key :

logging_config {
  include_cookies = "${var.log_include_cookies}"
  bucket = "${module.logs.bucket_domain_name}"
  prefix = "${var.log_prefix}"
}

The issue is that bucket is required if you have the logging_config key there.

I am getting "logging_config.0.bucket": required field is not set error.

locals {
  logging_config       = "${var.is_logging_enabled == "true" ? join(",", list(map(
      "include_cookies", var.log_include_cookies,
      "bucket", module.logs.bucket_domain_name,
      "prefix", var.log_prefix
    ))) : join(",", list(""))}"
}

resource "aws_cloudfront_distribution" "default" {
  ...
  logging_config = ["${compact(split(",", local.logging_config))}"]
}

but if I do this it works fine without the values being in there:

resource "aws_cloudfront_distribution" "default" {
  ...
  logging_config = []
}

I am willing to continue to work on it but I was wondering if you have any tips for conditional list like this. I was looking into overrides but before I spent my whole day trying to find a solution I thought it would be worth asking the community.

from terraform-aws-cloudfront-s3-cdn.

osterman avatar osterman commented on June 14, 2024

@catdevman what you'll want to do is use the join+splat pattern. Here's an example: https://github.com/cloudposse/terraform-aws-dynamodb-autoscaler/pull/10/files#diff-7a370d8342e7203b805911c92454f0f4R100

from terraform-aws-cloudfront-s3-cdn.

catdevman avatar catdevman commented on June 14, 2024

@osterman I looked over that and I am not sure that will work because this is a full map. I think that would work for individual keys but that didn't seemed to for the full map.

from terraform-aws-cloudfront-s3-cdn.

osterman avatar osterman commented on June 14, 2024

Ahk, you're right.

from terraform-aws-cloudfront-s3-cdn.

catdevman avatar catdevman commented on June 14, 2024

@osterman So I think this will all be fixed with Terraform 0.12 because of https://www.hashicorp.com/blog/terraform-0-12-conditional-operator-improvements. What I didn't know is what your process was for determining what the minimum version of Terraform should be for a module. I would hate to force people to upgrade if 0.12 just because of this feature but if it works for you it works for me.

from terraform-aws-cloudfront-s3-cdn.

JMGVDEV avatar JMGVDEV commented on June 14, 2024

Hi there -- i'm facing this same issue, i need to disable creation of s3 logs bucket and logging feature for CloudFront

is there any workaround for this?

Thanks for any suggestion/response

from terraform-aws-cloudfront-s3-cdn.

gugacavalieri avatar gugacavalieri commented on June 14, 2024

Hey guys!

Any updates on this?

I will be happy to help, have to do something similar for my work :)

from terraform-aws-cloudfront-s3-cdn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.