pulumi / pulumi-akamai

A Akamai Pulumi resource package, providing multi-language access to Akamai
Apache License 2.0
7 stars 3 forks source link

Akamai - Pulumi reverting back changes to v1 of akamai property when updating hostnames #388

Open deepakjd2004 opened 11 months ago

deepakjd2004 commented 11 months ago

What happened?

When updating hostname of a akamai property managed by pulumi - If we edit the hostnames of a property, the rules are reverted to the rules of v1. If we edit the rules of a property, the hostnames are reverted to the hostnames of v1.

Example

1) Create new property using pulumi python package 2) Do some changes in rules.json so that v2 is created 3) Add new hostname and execute pulumi 4) You would see that rules.json reverted to v1 and v2 changes are wiped off, new hostname added.. 5) Now again run pulumi up command without making any changes, this time v2 changes would be back but hosname added in step 3 is gone..

Sample code

import pulumi
import pulumi_akamai as akamai

product_id = "prd_Site_Accel"
contract_id = "ctr_1xxxxx"
group_id = "grp_xxxxx"

cpcode = akamai.CpCode(
    "pulumi-demo22Dec2023",
    product_id=product_id,
    contract_id=contract_id,
    group_id=group_id,
    name="pulumi",
)

edgehostname = akamai.EdgeHostName(
    "demo-pulumi22Dec2023",
    contract_id=contract_id,
    group_id=group_id,
    product_id="prd_Site_Accel",
    edge_hostname="pulumidemo22dec2023-web-learning-dj-xyz-edgesuite-net",
    ip_behavior="IPV4",
    status_update_emails=['xx@xx.com']
)
property = akamai.Property(
    "pulumiPropertyDemo22Dec2023",
    contract_id=contract_id,
    group_id=group_id,
    product_id=product_id,
    rule_format="latest",
    hostnames=[{
         'cname_from':'www.web-learning-djj.xyz',
         'cname_to':edgehostname.edge_hostname,
         'cert_provisioning_type':'CPS_MANAGED'},
         {'cname_from':'www.web-learning-djx.xyz',
         'cname_to':edgehostname.edge_hostname,
         'cert_provisioning_type':'CPS_MANAGED'}],
    rules=(lambda path: open(path).read())(
        f"default_rules.json"
    )
)

pulumi_staging = akamai.PropertyActivation(
    "pulumiStaging",
    property_id=property.id,
    network="STAGING",
    contacts=["xx@yy.com"],
    version=property.latest_version,
    auto_acknowledge_rule_warnings=True
)

pulumi.export("cpCode", cpcode.id)
pulumi.export("edgeHostName", edgehostname.edge_hostname)
pulumi.export("property_id", akamai_property.id)
pulumi.export("property_hostname", akamai_property.hostnames)

Output of pulumi about

pulumi about CLI Version 3.99.0 Go Version go1.21.5 Go Compiler gc

Plugins NAME VERSION akamai 6.3.1 python unknown

Host OS darwin Version 13.6 Arch x86_64

This project is written in python: executable='/Library/Frameworks/Python.framework/Versions/3.10/bin/python3' version='3.10.8'

Current Stack: qa

TYPE URN pulumi:pulumi:Stack urn:pulumi:qa::demo-22Dec2023::pulumi:pulumi:Stack::demo-22Dec2023-qa pulumi:providers:akamai urn:pulumi:qa::demo-22Dec2023::pulumi:providers:akamai::default_6_3_1 akamai:index/edgeHostName:EdgeHostName urn:pulumi:qa::demo-22Dec2023::akamai:index/edgeHostName:EdgeHostName::demo-pulumi22Dec2023 akamai:index/cpCode:CpCode urn:pulumi:qa::demo-22Dec2023::akamai:index/cpCode:CpCode::pulumi-demo22Dec2023 akamai:index/property:Property urn:pulumi:qa::demo-22Dec2023::akamai:index/property:Property::pulumiPropertyDemo22Dec2023 akamai:index/propertyActivation:PropertyActivation urn:pulumi:qa::demo-22Dec2023::akamai:index/propertyActivation:PropertyActivation::pulumiStaging

Found no pending operations associated with qa

Backend Name xxxxxxx URL file://~ User xxxxx Organizations Token type personal

Dependencies: NAME VERSION pip 23.3.2 pulumi-akamai 6.3.1 setuptools 69.0.2 wheel 0.42.0

Pulumi locates its logs in /var/folders/qj/tpkbgz8d2vxdqhyw9cmldb280000gp/T/ by default

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

iwahbe commented 11 months ago

Hey @deepakjd2004. Thanks for letting us know. It would be really helpful if you could elaborate on step 2 so we can reproduce the bug.


This sounds like an upstream bug, but I don't see an associated upstream issue. I think the next step is to recreate the sample program in TF and confirm that it still repros.

deepakjd2004 commented 11 months ago

Hey @iwahbe - Thanks for looking into it. I don't think it is upstream tf provider bug because i cannot replicate same behavior using terraform. In the step 2 make changes to default_rules.json i.e. the file that get passed to akamai.Property.rules. Make any change to default_rules.json(change any behavior, for e.g. update default origin.hostname to some other name, or update ttl or anything that does not cause schema validation issue, see below) so that pulumi sense it as a change and try to create a new version.

"rules": {
    "name": "default",
    "behaviors": [
      {
        "name": "origin",
        "options": {
          "cacheKeyHostname": "ORIGIN_HOSTNAME",
          "compress": true,
          "enableTrueClientIp": false,
          "forwardHostHeader": "REQUEST_HOST_HEADER",
          **"hostname": "somevalue.com",**
          "httpPort": 80,
          "httpsPort": 443,
          "originCertificate": "",
          "originSni": true,
          "originType": "CUSTOMER",
          "ports": "",
          "verificationMode": "PLATFORM_SETTINGS"
        }
Ankvi commented 3 months ago

I'm currently experiencing the same issue. I've got two properties, for our dev/test environments. They were pointing to some URL to begin with, then I changed the hostname of the dev environment by adding a -v2 suffix as I intend to migrate a service without having any downtime. Later on I changed the test environment too. Now, everytime I update the stack, both of these properties keep alternating between the first hostname and the new one, even if I haven't changed the input. Now, I could've worked around this if they were both rotating on the same two values, but they have opposing values, so I can never point to the same hostname on both services