akamai / cli-terraform

Akamai CLI plugin Admin Support for multiple OpenAPI resource types
Apache License 2.0
21 stars 11 forks source link

DXE-2936 export-imaging export outdated json instead of hcl #56

Closed fkieling closed 10 months ago

fkieling commented 11 months ago

Hi there,

Akamai CLI Version

akamai version 1.5.5 akamai terraform version 1.7.0

Expected Behavior

When I export the image manager configuration I get full hcl code. At least since version 3.5 the terraform datat source is supported. The current version of the terraform provider is 5.0. See: https://github.com/akamai/terraform-provider-akamai/issues/453.

`terraform { required_providers { akamai = { source = "akamai/akamai" version = ">= 5.0.0" } } required_version = ">= 0.13" }

provider "akamai" { edgerc = var.edgerc_path config_section = var.config_section }

resource "akamai_imaging_policy_set" "policyset" { name = "XXX" region = "EMEA" type = "IMAGE" contract_id = "ctr_XXX" }

resource "akamai_imaging_policy_image" "policy__auto" { policy_id = ".auto" contract_id = "ctr_XXX" policyset_id = akamai_imaging_policy_set.policyset.id activate_on_production = true json = file("_auto.json") }

resource "akamai_imaging_policy_image" "policy_policy1" { policy_id = "policy1" contract_id = "ctr_XXX" policyset_id = akamai_imaging_policy_set.policyset.id activate_on_production = true json = data.akamai_imaging_policy_image.policy1.json }

data "akamai_imaging_policy_image" "policy1" { policy { output { adaptive_quality = 50 } breakpoints { widths = [ 400, 650, 850, 1010 ] } } }`

Actual Behavior

When I export the image manager configuration I get an "imaging.tf" and much json-files:

imaging.tf:

`terraform { required_providers { akamai = { source = "akamai/akamai" version = ">= 2.0.0" } } required_version = ">= 0.13" }

provider "akamai" { edgerc = var.edgerc_path config_section = var.config_section }

resource "akamai_imaging_policy_set" "policyset" { name = "XXX" region = "EMEA" type = "IMAGE" contract_id = "ctr_XXX" }

resource "akamai_imaging_policy_image" "policy__auto" { policy_id = ".auto" contract_id = "ctr_XXX" policyset_id = akamai_imaging_policy_set.policyset.id activate_on_production = true json = file("_auto.json") }

resource "akamai_imaging_policy_image" "policy_policy1" { policy_id = "policy1" contract_id = "ctr_XXX" policyset_id = akamai_imaging_policy_set.policyset.id activate_on_production = true json = file("policy1.json") }`

policy1.json:

{ "breakpoints": { "widths": [ 400, 650, 850, 1010 ] }, "output": { "adaptiveQuality": 50 } }

mgwoj commented 11 months ago

I have noticed that README.md is missing description about --schema flag which generating data in the format you are expecting. However help command is mentioning about it:

  --schema                 Generate content of the policy using HCL instead of JSON file (default: false)
lkowalsk-akamai-com commented 11 months ago

README.md will be updated in comnig release. Description of the flag is already in the 'help' of the export-imaging comand.

lkowalsk-akamai-com commented 10 months ago

This issue should be resolved with recent release.