akamai / terraform-provider-akamai

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

SECKSD-28884 `akamai_appsec_configuration` unable to reference `data.akamai_group.group.id` #551

Open alexkunde opened 7 months ago

alexkunde commented 7 months ago

Terraform and Akamai Terraform Provider Versions

terraform -v                                                                                            1 х │ took 1m 11s │ azr-ed-efs_lmiv_kernanwendung-dev az │ at 13:27:24 
Terraform v1.8.2
on darwin_arm64
+ provider registry.terraform.io/akamai/akamai v6.1.0
+ provider registry.terraform.io/hashicorp/azurerm v3.100.0
+ provider registry.terraform.io/hashicorp/random v3.6.1
+ provider registry.terraform.io/hashicorp/time v0.11.1

Affected Resource(s)

Please list the resources as a list, for example:

Expected Behavior

When using akamai_appsec_configuration we need the group_id, which should be possible to get from data.akamai_group.group.id

Actual Behavior

akamai_appsec_configuration only expects the group id to be the numerical part whereas data.akamai_group.group.id will provide the number plus prefix

Planning failed. Terraform encountered an error while generating this plan.

╷
│ Error: Incorrect attribute value type
│ 
│   on akamai-property.tf line 63, in resource "akamai_appsec_configuration" "abc":
│   63:  group_id    = data.akamai_group.group.id
│     ├────────────────
│     │ data.akamai_group.group.id is "grp_123456"
│ 
│ Inappropriate value for attribute "group_id": a number is required.

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. create a new data source data.akamai_group.group.id
  2. create a new akamai_appsec_configuration
  3. set group_id = data.akamai_group.group.id
  4. terraform plan
ckulinsk commented 6 months ago

Hello @alexkunde ,

Appsec documentation suggests obtaining of the group id from data.akamai_appsec_contracts_groups.contracts_groups datasource: https://techdocs.akamai.com/terraform/docs/as-ds-contracts-groups

If you would like to use data.akamai_group.group.id I would suggest parsing it: parseint(replace(data.akamaigroup.group.id, "grp", ""), 10)

Best regards, Cyryl

alexkunde commented 6 months ago

Hi @ckulinsk, thank you for the workaround, but wouldn't it be preferable to not have to use additional functions to implement this with the data field?

Best, Alexander