akamai / terraform-provider-akamai

Terraform Akamai provider
https://www.terraform.io/docs/providers/akamai/
Mozilla Public License 2.0
109 stars 96 forks source link

Passing parameters without using json #367

Closed Manikandanmuru closed 1 year ago

Manikandanmuru commented 1 year ago

Hi there,

Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html.

Terraform Version Terraform v1.3.4 on linux_amd64

Affected Resource(s) Please list the resources as a list, for example: akamai_property_rules

Expected Behavior We want to avoid the JSON rule file in our Terraform code, so we have decided to create the property with defined rules and use it as a template for new property creation refer #356. And the below option works well.

data "akamai_property" "property" { name = "akamai-rule-template.xxxxx.cloud.xxxx.com" version = "1" }

But we want to pass the parameters for ORIGIN_HOSTNAME and Origin Certificate while creating the new property. Can we able to pass the parameters without using the JSON file? or alternate method to pass the parameters using the above method??

{ "name": "origin", "options": { "cacheKeyHostname": "REQUEST_HOST_HEADER", "compress": XXX, "enableTrueClientIp": XXX, "forwardHostHeader": "ORIGIN_HOSTNAME", "httpPort": XX, "httpsPort": XXX, "originSni": XXX, "originType": "CUSTOMER", "verificationMode": "PLATFORM_SETTINGS", "hostname": "{{user.PMUSER_ORIGIN}}", "originCertificate": "", "ports": "" } },

BAu0002 commented 1 year ago

The bottom of https://registry.terraform.io/providers/akamai/akamai/2.4.2/docs/guides/get_started_property show you to pass variable into the json file and then you add ${env.originalHostname}" to your json

`data "akamai_property_rules_template" "example" { template_file = abspath("${path.root}/rules/main.json") variables { name = "originalHostname" value = var.hostname type = "string" } }

resource "akamai_property" "example" { ... rules = data.akamai_property_rules_template.example.json }`

Manikandanmuru commented 1 year ago

Hi @BAu0002

Thank you but my ask did we have any other alternative method to pass the variable without using the "Json" file.

Iam using the below method to create the property that is without using json file

data "akamai_property" "property" { name = "akamai-rule-template.xxxxx.cloud.xxxx.com" version = "1" }

wzagrajcz commented 1 year ago

Hello, We are currently working on evaluating the solution for passing rules without json and to declare each rule on terraform level. It's on quite early stage so I cannot guarantee that it will be finished or when. As per now as @BAu0002 suggested, passing through the env variable should work.

Thanks and best regards, Wojciech

sorrel340 commented 1 year ago

This is something I would also like very much across the Akamai TF as a whole, which uses JSON far too much.

The new bot-manager system seems to use JSON for almost everything, even for basic actions, which surely should be parameters/variables, not JSON files for the single word "Deny".

lkowalsk-akamai-com commented 1 year ago

Please check out new 3.5.0 release which was now declarative option for property manager. I will close this ticket, feel free to open now one if needed.

renatotecchio commented 1 year ago

Hi @lkowalsk-akamai-com could you open this issue again? I'm facing three problems when using property manager with declarative option.

In the behavior -> origin block I need to pass the custom certificates but Terraform is not accepting it:

    behavior {
      origin {
       ...
        custom_certificates = [
          {
            subject_CN = "istio-ingressgateway.istio-system.svc"
            subject_alternative_names = ["istio-ingressgateway.istio-system.svc", "istio-ingressgateway.istio-system.svc.cluster.local"]
            subject_RDNs = {
              CN = "istio-ingressgateway.istio-system.svc"
            }     
            not_after = "${env.akamai_origin_certificate_expire}"
            sha1_fingerprint = "${env.akamai_origin_certificate_sha}"
            pem_encoded_cert = "${env.akamai_origin_certificate}"
          }
        ]
      }
    }

Terraform message: An argument named "custom_certificates" is not expected here. Did you mean to define a block of type "custom_certificates"?

In the behavior -> cp_code block I need to pass the cp_code_limits but Terraform is not accepting it:

    behavior {
      cp_code {
        value {
          ...
          cp_code_limits = {
            limit = 100
            current_capacity = 96
            limit_type = global
          }
        }
      }
    }

Terraform message: An argument named "cp_code_limits" is not expected here. Did you mean to define a block of type "cp_code_limits"?

In the behavior -> site_shield block I need to pass the has_mixed_hosts and src but Terraform is not accepting it:

    behavior {
      site_shield {
        ssmap {
         ...
          has_mixed_hosts = false
          src = "PREVIOUS_MAP"
        }
      }
    }

Terraform message: An argument named "has_mixed_hosts" is not expected here. An argument named "src" is not expected here.

wzagrajcz commented 1 year ago

Hello @renatotecchio Can you please rather open new issue under this project for your issue? Additionally in that new ticket please mention: which provider version and Terraform version you use and what are the values for product_id and rule_format (in akamai_property resource)

Thanks and best regards, Wojciech

Edit: On first glance I've notice some syntax issues in issue 2. Please try:

    behavior {
      cp_code {
        value {
          ...
          cp_code_limits {
            limit = 100
            current_capacity = 96
            limit_type = global
          }
        }
      }
    }

If it won't help let's continue this conversation in new ticket.