Skip to content

Commit

Permalink
Fixed typos, formatting, updated authentication description, removed …
Browse files Browse the repository at this point in the history
…product disclaimer.
  • Loading branch information
estherBeyda committed Sep 17, 2024
1 parent 9b4727e commit 26cf29e
Show file tree
Hide file tree
Showing 18 changed files with 150 additions and 108 deletions.
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Qwilt Terraform Provider

> ⚠️ **Disclaimer**: This provider is currently in limited availability.
## Requirements

- [Terraform](https://developer.hashicorp.com/terraform/downloads) >= 1.0
Expand All @@ -11,11 +9,11 @@

1. Clone the repository.
1. Enter the repository directory.
1. Build the provider using the Go `install` command:
1. Build the provider using the Go install command:

```shell
go install
```
```shell
go install
```

## Adding Dependencies

Expand Down
2 changes: 1 addition & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The document generation tool looks for files in the following locations by defau
* **data-sources/`full data source name`/data-source.tf** example file for the named data source page
* **resources/`full resource name`/resource.tf** example file for the named data source page

Run: go generate -v ./... to generate documentation
Run: ```go generate -v ./...``` to generate documentation.


The sample configuration files under Playground demonstrate how to use the Qwilt Terraform provider. They can be used as starter files for provisioning and managing resources via the Terraform CLI. They are designed for customization-- replace placeholder values with your own specific configuration details. Replace the example certificate and key values with your own.
12 changes: 6 additions & 6 deletions examples/playground/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Qwilt Provider Usage Examples

This examples in this directory demonstrate how to use the Qwilt Terraform Provider. They cover various common use cases.
The examples in this directory demonstrate how to use the Qwilt Terraform Provider. They cover various common use cases.

Inside this directory, you will find the following examples:
* *provider-install-verification*: Demonstrates how to confirm that the Qwilt Terraform Provider is installed correctly.
* *qwilt-config-basic*: Demonstrates how to configure a single site, site configuration, certificate, and activation resource.
* *qwilt-config-multi*: Demonstrates how to manage two sites, site configurations, certificates, and activation resources within a single Terraform configuration.
* *qwilt-config-multi-workspace*: (Advanced) Demonstrates how to use the Terraform workspaces capability to manage multiple instances of the same configuration. Specifically, this example illustrates how to manage both production and non-production instances of a configuration that defines two sites.
* *qwilt-datasource*: A practical example demonstrating how to use the *sites* and *certificates* data sources to query various resources.
* **provider-install-verification**: Demonstrates how to confirm that the Qwilt Terraform Provider is installed correctly.
* **qwilt-config-basic**: Demonstrates how to configure a single site, site configuration, certificate, and activation resource.
* **qwilt-config-multi**: Demonstrates how to manage two sites, site configurations, certificates, and activation resources within a single Terraform configuration.
* **qwilt-config-multi-workspace**: (Advanced) Demonstrates how to use the Terraform Workspaces capability to manage multiple instances of the same configuration. Specifically, this example illustrates how to manage both production and non-production instances of a configuration that defines two sites.
* **qwilt-datasource**: A practical example demonstrating how to use the *sites* and *certificates* data sources to query various resources.


**TIP:** The sample configuration files in this directory can also be used as starter files for provisioning and managing resources via the Terraform CLI. They are designed for customization-- replace placeholder values with your own specific configuration details. Replace the example certificate and key values with your own.
12 changes: 9 additions & 3 deletions examples/playground/qwilt-config-basic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,23 @@

This is a simple example demonstrating how to configure a single site, site configuration, certificate, and activation resource.

In this example, the host_index JSON configuration is embedded in main.tf.
In this example, the host_index JSON configuration is embedded in *main.tf*.

If you prefer to maintain the SVTA configuration in a separate file, remove the embedded host_index, and instead use the reference to *examplesitebasic.json*:

```host_index = file("./examplesitebasic.json")```


If you prefer to maintain the SVTA configuration in a separate file, remove the embedded host_index, and use the reference to "examplesitebasic.json" ```host_index = file("./examplesitebasic.json")``` instead.

To use this example:

1. Make sure your QCDN_API_KEY env variable is set. (This is the recommended authentication method.)

For more information on authentication, see the provider documentation, which also covers alternative methods.

2. Replace the placeholder values with your own specific configuration details. Replace the example certificate and key values with your own.
2. Replace the placeholder values with your own specific configuration details.

Replace the example certificate and key values with your own.

3. Apply the configuration:

Expand Down
34 changes: 20 additions & 14 deletions examples/playground/qwilt-config-multi-workspace/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Qwilt Multi-Config Resource Example Using Workspaces
# Qwilt Use Workspaces to Manage Multiple Instances of a TF Config Example

⚠️This is our most complex example. If you are not yet comfortable using the Qwilt Terraform Provider, we suggest reviewing the other examples first.

Expand All @@ -20,31 +20,37 @@ To use this example:

For example, to create workspaces for production and development, run the following commands:



```
$ terraform workspace new prod
Created and switched to workspace "prod"!
```
You created and switched to the workspace "prod."
You're now in a new, empty workspace. Workspaces isolate their state, so when you run Terraform plan, Terraform will not detect any existing state for this configuration.
Since you're in a new, empty workspace and workspaces keep their state isolated, running terraform plan will not detect any existing state for this configuration.
```
$ terraform workspace new dev
Created and switched to workspace "dev"!
```
You're now in a new, empty workspace. Workspaces isolate their state, so when you run terraform plan, Terraform will not detect any existing state for this configuration.
You created and switched to the workspace "dev."
$ terraform workspace list
default
* dev
prod
```
Since you're in a new, empty workspace and workspaces keep their state isolated, running terraform plan will not detect any existing state for this configuration.
```
$ terraform workspace list
default
* dev
prod
```
Terraform will now track separate states for each environment. You must switch to an environment to operate within it. For example, to apply the production configuration, switch to the production workspace:
```
$ terraform workspace select prod
Switched to workspace "prod".
```
$ terraform workspace select prod
```
3. Switch to the desired workspace and apply the configuration:
3. After switching to the desired workspace, apply the configuration:
```
$ terraform apply
Expand Down
6 changes: 4 additions & 2 deletions examples/playground/qwilt-config-multi/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Qwilt Multi-Config Resource Example
# Qwilt Multi-Site TF Config Example

This is a more complex example demonstrating how to manage two sites, site configurations, certificates, and activation resources in a single configuration.

Expand All @@ -10,7 +10,9 @@ To use this example:

For more information on authentication, see the provider documentation, which also covers alternative methods.

2. Replace the placeholder values with your own specific configuration details. Replace the example certificate and key values with your own.
2. Replace the placeholder values with your own specific configuration details.

Replace the example certificate and key values with your own.

3. Apply the configuration:

Expand Down
46 changes: 24 additions & 22 deletions examples/playground/qwilt-datasource/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,27 @@ $ terraform plan
A common use case for using the data source is to find your site information so that you can import it into a Terraform configuration.

To search for a site by name, do this:
```
$ terraform plan -var="site_name=example.com"
```
The above command launches a substring match of the site_name attribute of each defined site and outputs the matching site_ids.

```
$ terraform plan -var="site_name=example.com"
```

The above command launches a substring match of the site_name attribute of each defined site and outputs the matching site_ids.


To retrieve a list of all sites, do this:

```
$ terraform plan -var="site_id=all"
```
```
$ terraform plan -var="site_id=all"
```

Once you have identified the site_id that you are targeting, you may search for it directly:

```
$ terraform plan -var="site_id=<SiteID>"
```
```
$ terraform plan -var="site_id=<SiteID>"
```

The output includes details about the specified site_id, and a list of associated site configurations (i.e. revisions) and publishing operations (i.e. site activations).
The output includes details about the specified site_id, and a list of associated site configurations (i.e. revisions) and publishing operations (i.e. site activations).

## Site Configuration and Activation Lookup

Expand All @@ -49,24 +51,24 @@ The same logic can be applied to certificates. Certificates can be queried by d

To search for certificates by domain name:

```
$ terraform plan -var="cert_domain=example.com"
```
The above command launches a substring match of the cert_domain attribute for each defined certificate and outputs the matching cert_ids.
```
$ terraform plan -var="cert_domain=example.com"
```
The above command launches a substring match of the cert_domain attribute for each defined certificate and outputs the matching cert_ids.


To retrieve a list of all certificates, do this:

```
$ terraform plan -var="cert_id=all"
```
```
$ terraform plan -var="cert_id=all"
```

Once you have identified the cert_id that you are targeting, you may search for it directly:

```
$ terraform plan -var="cert_id=<CertificateID>"
```
The output provides details about the specified cert_id.
```
$ terraform plan -var="cert_id=<CertificateID>"
```
The output provides details about the specified cert_id.

## About This Example

Expand Down
6 changes: 3 additions & 3 deletions examples/playground/qwilt-datasource/outputs-certificates.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Output a cert list if cert_id is "all" and cert_domain isn't defined
# Output a cert list if cert_id is "all" and cert_domain isn't defined.
output "certificates_list" {
value = var.cert_id == "all" && var.cert_domain == null ? [for cert in data.qwilt_cdn_certificates.detail.certificate : { domain = cert.domain, cert_id = cert.cert_id }] : null
}
Expand All @@ -8,12 +8,12 @@ output "cert_list_by_cert_domain" {
value = var.cert_domain != null ? [for cert in data.qwilt_cdn_certificates.detail.certificate : { cert_domain = cert.domain, cert_id = cert.cert_id } if strcontains(cert.domain, var.cert_domain)] : null
}

# Output the details of a matching cert if cert_id is set to an explicit value
# Output the details of a matching cert if cert_id is set to an explicit value.
output "cert_detail" {
value = var.cert_id == "all" || var.cert_id == null || data.qwilt_cdn_certificates.detail.certificate == null ? null : data.qwilt_cdn_certificates.detail.certificate[0]
}

# Output to dump every attribute of every certificate available to users in your org (probably not what you want)
# Output to dump every attribute of every certificate available to users in your org.
#output "all_certs" {
# value = data.qwilt_cdn_certificates.detail
#}
8 changes: 4 additions & 4 deletions examples/playground/qwilt-datasource/outputs-publishops.tf
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# Output the publish_ops list of a site if site_id is not "all", but revision_id and publish_id are not defined
# Output the publish_ops list of a site if site_id is not "all", but revision_id and publish_id are not defined.
output "publish_ops_list" {
value = var.site_id != "all" && data.qwilt_cdn_sites.detail.publish_op != null && var.publish_id == "all" && var.revision_id == "all" ? [for publish_op in data.qwilt_cdn_sites.detail.publish_op : publish_op] : null
}

# Output the publish_ops belonging to revision_id of a site if site_id and revision_id are defined, and publish_id is not defined
# Output the publish_ops belonging to revision_id of a site if site_id and revision_id are defined, and publish_id is not defined.
output "publish_ops_list_by_revision_id" {
value = data.qwilt_cdn_sites.detail.publish_op != null && var.site_id != "all" && var.revision_id != "all" && var.publish_id == "all" ? [for publish_op in data.qwilt_cdn_sites.detail.publish_op : publish_op if publish_op.revision_id == var.revision_id] : null
}

# Output the publish_ops detail for an active job of a revision_id
# Output the publish_ops detail for an active job of a revision_id.
output "publish_ops_list_by_revision_id_active" {
value = data.qwilt_cdn_sites.detail.publish_op != null && var.site_id != "all" && var.revision_id != "all" && var.publish_id == "all" ? [for publish_op in data.qwilt_cdn_sites.detail.publish_op : publish_op if publish_op.revision_id == var.revision_id && publish_op.is_active == true] : null
}

# Output the publish_ops detail of a matching operation if site_id and publish_id are set to explicit values
# Output the publish_ops detail of a matching operation if site_id and publish_id are set to explicit values.
output "publish_op_detail" {
value = var.site_id == "all" || var.publish_id == "all" || data.qwilt_cdn_sites.detail.publish_op == null ? null : data.qwilt_cdn_sites.detail.publish_op[0]
}
4 changes: 2 additions & 2 deletions examples/playground/qwilt-datasource/outputs-revisions.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Output the revision list of a site if site_id is not "all", and revision_id is not defined
# Output the revision list of a site if site_id is not "all", and revision_id is not defined.
output "revisions_list" {
value = var.site_id != "all" && data.qwilt_cdn_sites.detail.revision != null && var.revision_id == "all" ? [for revision in data.qwilt_cdn_sites.detail.revision : { revision_id = revision.revision_id, revision_num = revision.revision_num, change_description = revision.change_description }] : null
}

# Output the revision detail of a matching revision if site_id and revision_id are set to explicit values
# Output the revision detail of a matching revision if site_id and revision_id are set to explicit values.
output "revision_detail" {
value = var.site_id == "all" || var.revision_id == "all" || data.qwilt_cdn_sites.detail.revision == null ? null : data.qwilt_cdn_sites.detail.revision[0]
}
8 changes: 4 additions & 4 deletions examples/playground/qwilt-datasource/outputs-sites.tf
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# Output a site list if site_id is "all" and site_name isn't defined
# Output a site list if site_id is "all" and site_name isn't defined.
output "sites_list" {
value = var.site_id == "all" && var.site_name == null ? [for site in data.qwilt_cdn_sites.detail.site : { site_name = site.site_name, site_id = site.site_id }] : null
}

# Output a matching site list if site_name is defined
# Output a matching site list if site_name is defined.
output "sites_list_by_site_name" {
value = var.site_name != null ? [for site in data.qwilt_cdn_sites.detail.site : { site_name = site.site_name, site_id = site.site_id } if strcontains(site.site_name, var.site_name)] : null
}

# Output the detail of a matching site if site_id is set to an explicit value
# Output the detail of a matching site if site_id is set to an explicit value.
output "site_detail" {
value = var.site_id == "all" || var.site_id == null || data.qwilt_cdn_sites.detail.site == null ? null : data.qwilt_cdn_sites.detail.site[0]
}

# Output to dump every attribute of every site available to your user (probably not what you want)
# Output to dump every attribute of every site available to your user.
#output "all_sites" {
# value = data.qwilt_cdn_sites.detail
#}
13 changes: 10 additions & 3 deletions examples/playground/qwilt-import/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,35 @@ Basic import uses the site_id to automatically detect the revison_id and publish

The logic for determining which qwilt_cdn_site_configuration to import is:
1. If there is an active published version, it is imported.
2. If there is no active published version, the most recently published version is imported.
2. If there is no active published version, the most recently published version is imported.
3. If the site has never been published, the most recently saved configuration version is imported. (The version with the highest revision_Id value - max revision_number.)

To complete the import process, implement the following steps for each resource:
1. Make sure your QCDN_API_KEY env variable is set.
2. Perform terraform import. (See below.)
2. Verify the import was completed successfully.
3. Use the attribute values from the terraform state to generate the configurable attributes in the .tf file for the particular resource.
4. Change the following id's to references to allow for implicit dependencies:
4. Change the following ids to references to allow for implicit dependencies:
- *site_id* in the *site_configuration* resource.
- *site_id*, *revision_id*, and *certificate_id* in the *site_activation* resource.
5. Run ```terraform plan``` - expect no changes.


The Terraform import command for each of the resources:

```
$ terraform import qwilt_cdn_certificate.example <cert_id> -var="token=<API Token>"
$ terraform import qwilt_cdn_site.example <site_id> -var="token=<API Token>"
$ terraform import qwilt_cdn_site_configuration.example <site_id> -var="token=<API Token>"
$ terraform import qwilt_cdn_site_activation.example <site_id> -var="token=<API Token>"
```

## Advanced Import

Advanced import lets the user explicitly select revision_id for site_configuration and publish_id for site_activation.
Advanced import lets the user explicitly select *revision_id* for site_configuration and *publish_id* for site_activation.


1. Make sure your QCDN_API_KEY env variable is set.
Expand All @@ -52,7 +56,10 @@ Advanced import lets the user explicitly select revision_id for site_configurati
The Terraform import command for each of the resources:
```
$ terraform import qwilt_cdn_certificate.example <cert_id> -var="token=<API Token>"
$ terraform import qwilt_cdn_site.example <site_id> -var="token=<API Token>"
$ terraform import qwilt_cdn_site_configuration.example <site_id>:<revision_id> -var="token=<API Token>"
$ terraform import qwilt_cdn_site_activation.example <site_id>:<publish_id> -var="token=<API Token>"
```
Loading

0 comments on commit 26cf29e

Please sign in to comment.