Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dictionary to Compute service #361

Merged
merged 2 commits into from
Feb 9, 2021
Merged

Add Dictionary to Compute service #361

merged 2 commits into from
Feb 9, 2021

Conversation

sazor
Copy link
Contributor

@sazor sazor commented Jan 31, 2021

Dictionary should behave the same way in both usual vcl services and compute (wasm) services. Therefore, PR simply adds dictionary attribute to compute services.
Manually tested with actual fastly compute service.
Related Issue #360

@Integralist
Copy link
Collaborator

Thanks for the PR @sazor the code looks fine to me, but I just need to validate the changes locally.

I hope to get round to this soon, but wanted to let you know in any case that I'm aware of your changes 👍🏻

@Integralist Integralist added the enhancement New feature or request label Feb 3, 2021
@Integralist
Copy link
Collaborator

Just wanted to circle back around to this PR to say I've validated the code works with a real service. I did this by first validating the current provider version 0.24.0 doesn't support a dictionary block, before using terraform's TF_CLI_CONFIG_FILE to repoint the provider's binary to one that was compiled from this PR's source code (for more details see):

$ terraform init

Initializing the backend...

Initializing provider plugins...
- Reusing previous version of fastly/fastly from the dependency lock file
- Installing fastly/fastly v0.24.0...
- Installed fastly/fastly v0.24.0 (signed by a HashiCorp partner, key ID 508A0A1DCC9FE27E)

...

Terraform has been successfully initialized!

...

If I try to run a plan I'll see an expected error:


Error: Unsupported block type

  on service.tf line 34, in resource "fastly_service_compute" "test_service":
  34:   dictionary {

Blocks of type "dictionary" are not expected here.

Next, I repoint the provider binary and reinitialize terraform (notice the warning that the original provider isn't being used):

                                                                                                                                                                                                                                             $ terraform init

Initializing the backend...

Initializing provider plugins...
- Reusing previous version of fastly/fastly from the dependency lock file
- Installing fastly/fastly v0.24.0...
- Installed fastly/fastly v0.24.0 (signed by a HashiCorp partner, key ID 508A0A1DCC9FE27E)

...

Warning: Provider development overrides are in effect

The following provider development overrides are set in the CLI configuration:
 - fastly/fastly in /Users/integralist/Code/terraform/terraform-provider-fastly

The behavior may therefore not match any released version of the provider and
applying changes may cause the state to become incompatible with published
releases.

Terraform has been successfully initialized!

...

Now when I try to run a plan it succeeds.

$ terraform plan

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # fastly_service_compute.test_service will be created
  + resource "fastly_service_compute" "test_service" {
      + activate       = true
      + active_version = (known after apply)
      + cloned_version = (known after apply)
      + comment        = "Managed by Terraform"
      + force_destroy  = true
      + id             = (known after apply)
      + name           = "compute_dictionary"

      + backend {
          + address               = "httpbin.org"
          + auto_loadbalance      = true
          + between_bytes_timeout = 10000
          + connect_timeout       = 1000
          + error_threshold       = 0
          + first_byte_timeout    = 15000
          + max_conn              = 200
          + name                  = "test-backend"
          + port                  = 80
          + ssl_check_cert        = true
          + use_ssl               = false
          + weight                = 100
        }

      + dictionary {
          + dictionary_id = (known after apply)
          + name          = "My Dictionary"
          + write_only    = false
        }

      + domain {
          + comment = "test-domain"
          + name    = "integralist-computedict.edgecompute.app"
        }

      + package {
          + filename         = "package-built-locally-via-cli.tar.gz"
          + source_code_hash = "..."
        }
    }

  # fastly_service_dictionary_items_v1.items["My Dictionary"] will be created
  + resource "fastly_service_dictionary_items_v1" "items" {
      + dictionary_id = (known after apply)
      + id            = (known after apply)
      + items         = {
          + "key1" = "value1"
          + "key2" = "value2"
        }
      + service_id    = (known after apply)
    }

Plan: 2 to add, 0 to change, 0 to destroy.

Although I don't show it here, I have successfully run the terraform apply and manually validated the resources were created correctly.

@Integralist
Copy link
Collaborator

@sazor are you able to rebase in master as there's a new CI docs workflow I want to be sure is run. Thanks!

@sazor
Copy link
Contributor Author

sazor commented Feb 9, 2021

Sure, thanks!

@Integralist Integralist merged commit 8f24204 into fastly:master Feb 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants