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

Release/v1.9.0 #59

Merged
merged 8 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# Release Notes

## Version 1.9.0 (August 29, 2023)

### Features/Enhancements

* [IMPORTANT] CloudWrapper
* Added support for `export-cloudwrapper` command which allows export of `akamai_cloudwrapper_configuration` and `akamai_cloudwrapper_activation` resources

* APPSEC
* Added import support for custom client sequence

### Bug fixes

* Image and Video Manager
* Added description for `--schema` flag for `export-imaging` command in `README.md` ([#56](https://github.com/akamai/cli-terraform/issues/56))

* PAPI
* Fixed `export-property` command to export `akamai_property_activation` resource attributes for latest active version.
* Fixed `export-property` command to use `group_id` and `contract_id` as terraform variables, instead of data sources, which
produced inconsistencies ([I#374](https://github.com/akamai/terraform-provider-akamai/issues/426))
* `logStreamName` field from `datastream` behavior has changed from string to array of strings for rule
format `v2023-05-30` ([#58](https://github.com/akamai/cli-terraform/issues/58))

## Version 1.8.0 (August 1, 2023)

### Features/Enhancements
Expand Down
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Description:
Administer and manage available Akamai resources with Terraform

Built-In Commands:
export-cloudwrapper
export-domain (alias: create-domain)
export-zone (alias: create-zone)
export-appsec (alias: create-appsec)
Expand Down Expand Up @@ -226,6 +227,23 @@ Flags:
$ akamai terraform export-cloudlets-policy
```

## CloudWrapper

### Usage

```
akamai terraform [global flags] export-cloudwrapper [flags] <configuration_id>

Flags:
--tfworkpath path Directory used to store files created when running commands. (default: current directory)
```

### Export CloudWrapper configuration.

```
$ akamai terraform export-cloudwrapper
```

## EdgeWorkers

### Export EdgeKV Usage
Expand Down Expand Up @@ -292,6 +310,7 @@ $ akamai terraform export-iam
Flags:
--tfworkpath path Directory used to store files created when running commands. (default: current directory)
--policy-json-dir path Path location for placement of policy jsons. Default: same value as tfworkpath
--schema Generate content of the policy using HCL instead of JSON file (default: false)
```

### Export Image and Video policy configuration.
Expand Down
2 changes: 1 addition & 1 deletion cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"commands": [
{
"name": "terraform",
"version": "1.8.0",
"version": "1.9.0",
"description": "Administer and Manage Akamai Terraform configurations",
"bin": "https://github.com/akamai/cli-terraform/releases/download/v{{.Version}}/akamai-{{.Name}}-{{.Version}}-{{.OS}}{{.Arch}}{{.BinSuffix}}",
"auto-complete": true,
Expand Down
2 changes: 1 addition & 1 deletion cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (

var (
// Version holds current version of cli-terraform
Version = "1.8.0"
Version = "1.9.0"
)

// Run initializes the cli and runs it
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/akamai/cli-terraform
go 1.18

require (
github.com/akamai/AkamaiOPEN-edgegrid-golang/v7 v7.1.0
github.com/akamai/AkamaiOPEN-edgegrid-golang/v7 v7.2.1
github.com/akamai/cli v1.5.5
github.com/fatih/color v1.13.0
github.com/hashicorp/hcl/v2 v2.11.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDO
github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8=
github.com/agext/levenshtein v1.2.1 h1:QmvMAjj2aEICytGiWzmxoE0x2KZvE0fvmqMOfy2tjT8=
github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
github.com/akamai/AkamaiOPEN-edgegrid-golang/v7 v7.1.0 h1:QBcW0BOSLBN2DGgs6je3L/E/S3nCKhi4Me4oijT44Dw=
github.com/akamai/AkamaiOPEN-edgegrid-golang/v7 v7.1.0/go.mod h1:zZWAMUwE4q5sVPgnjz9jiqtXA01tM3m9HYd6Wk0ev90=
github.com/akamai/AkamaiOPEN-edgegrid-golang/v7 v7.2.1 h1:amPKOiXDgUXQcSMMg0XXvOZkF9sQcffZXZrZT4VJ3z0=
github.com/akamai/AkamaiOPEN-edgegrid-golang/v7 v7.2.1/go.mod h1:zZWAMUwE4q5sVPgnjz9jiqtXA01tM3m9HYd6Wk0ev90=
github.com/akamai/cli v1.5.5 h1:XKubVW8WOVP8qcgJRK2MOj8HeqC4kudvSOM0m8mJsj0=
github.com/akamai/cli v1.5.5/go.mod h1:29wClp63PEEkpDLxtqM/JrVmnwOCSaE+itIJjCAIECE=
github.com/andres-erbsen/clock v0.0.0-20160526145045-9e14626cd129 h1:MzBOUgng9orim59UnfUTLRjMpd09C5uEVQ6RPGeCaVI=
Expand Down
17 changes: 17 additions & 0 deletions pkg/commands/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package commands
import (
"github.com/akamai/cli-terraform/pkg/providers/appsec"
"github.com/akamai/cli-terraform/pkg/providers/cloudlets"
"github.com/akamai/cli-terraform/pkg/providers/cloudwrapper"
"github.com/akamai/cli-terraform/pkg/providers/cps"
"github.com/akamai/cli-terraform/pkg/providers/dns"
"github.com/akamai/cli-terraform/pkg/providers/edgeworkers"
Expand Down Expand Up @@ -152,6 +153,22 @@ func CommandLocator() ([]*cli.Command, error) {
BashComplete: autocomplete.Default,
})

commands = append(commands, &cli.Command{
Name: "export-cloudwrapper",
Description: "Generates Terraform configuration for CloudWrapper resources",
Usage: "export-cloudwrapper",
ArgsUsage: "<config_id>",
Action: validatedAction(cloudwrapper.CmdCreateCloudWrapper, requireValidWorkpath, requireNArguments(1)),
Flags: []cli.Flag{
&cli.StringFlag{
Name: "tfworkpath",
Usage: "Directory used to store files created when running commands.",
DefaultText: "current directory",
},
},
BashComplete: autocomplete.Default,
})

commands = append(commands, &cli.Command{
Name: "export-cloudlets-policy",
Aliases: []string{"create-cloudlets-policy"},
Expand Down
30 changes: 30 additions & 0 deletions pkg/providers/appsec/create_appsec.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ func CmdCreateAppsec(c *cli.Context) error {
"exportJSONWithoutKeys": exportJSONWithoutKeys,
"getCustomBotCategoryResourceNamesByIDs": getCustomBotCategoryResourceNamesByIDs,
"getCustomBotCategoryNameByID": getCustomBotCategoryNameByID,
"getCustomClientResourceNamesByIDs": getCustomClientResourceNamesByIDs,
}

// The template processor
Expand Down Expand Up @@ -561,3 +562,32 @@ func getCustomBotCategoryResourceNamesByIDs(customBotCategories []map[string]int
}
return strings.Join(categoryResourceNames, ","), nil
}

// getCustomClientResourceNamesByIDs returns comma separated custom-client resource names in the same order as the provided customClientIDs
func getCustomClientResourceNamesByIDs(customClients []map[string]interface{}, customClientIDs []string) (string, error) {
customClientMap := make(map[string]string)
for _, customClient := range customClients {
customClientName, ok := customClient["customClientName"].(string)
if !ok {
return "", fmt.Errorf("cannot convert custom client name %s to string", customClient["customClientName"])
}
name, err := tools.EscapeName(customClientName)
if err != nil {
return "", err
}
customClientID, ok := customClient["customClientId"].(string)
if !ok {
return "", errors.New("cannot convert customClientId to string")
}
customClientMap[customClientID] = name
}
customClientResourceNames := make([]string, len(customClientIDs))
for i, customClientID := range customClientIDs {
customClientName, ok := customClientMap[customClientID]
if !ok {
return "", fmt.Errorf("cannot find custom client name for id %s", customClientID)
}
customClientResourceNames[i] = fmt.Sprintf("akamai_botman_custom_client.%s_%s.custom_client_id", customClientName, customClientID)
}
return strings.Join(customClientResourceNames, ",\n"), nil
}
2 changes: 2 additions & 0 deletions pkg/providers/appsec/create_appsec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ func TestProcessPolicyTemplates(t *testing.T) {
"exportJSONWithoutKeys": exportJSONWithoutKeys,
"getCustomBotCategoryNameByID": getCustomBotCategoryNameByID,
"getCustomBotCategoryResourceNamesByIDs": getCustomBotCategoryResourceNamesByIDs,
"getCustomClientResourceNamesByIDs": getCustomClientResourceNamesByIDs,
}

// Template to path mappings
Expand Down Expand Up @@ -421,6 +422,7 @@ func TestProcessPolicyTemplatesWithBotman(t *testing.T) {
"exportJSONWithoutKeys": exportJSONWithoutKeys,
"getCustomBotCategoryNameByID": getCustomBotCategoryNameByID,
"getCustomBotCategoryResourceNamesByIDs": getCustomBotCategoryResourceNamesByIDs,
"getCustomClientResourceNamesByIDs": getCustomClientResourceNamesByIDs,
}

// Template to path mappings
Expand Down
3 changes: 3 additions & 0 deletions pkg/providers/appsec/templates/imports.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ terraform import module.security.akamai_botman_custom_defined_bot.{{escapeName (
terraform import module.security.akamai_botman_custom_client.{{escapeName (index . "customClientName")}}_{{index . "customClientId"}} {{ $configID }}:{{index . "customClientId"}}
{{ end -}}
{{ end -}}
{{ if .CustomClientSequence -}}
terraform import module.security.akamai_botman_custom_client_sequence.sequence {{ $configID }}
{{ end -}}
{{ if .ResponseActions -}}
{{ if .ResponseActions.ServeAlternateActions -}}
{{ range .ResponseActions.ServeAlternateActions -}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,11 @@ resource "akamai_botman_custom_client" "{{ escapeName (index . "customClientName

{{ end -}}
{{ end -}}
{{ if .CustomClientSequence -}}
resource "akamai_botman_custom_client_sequence" "sequence" {
config_id = akamai_appsec_configuration.config.config_id
custom_client_ids = [
{{getCustomClientResourceNamesByIDs .CustomClients .CustomClientSequence}}
]
}
{{ end -}}
4 changes: 4 additions & 0 deletions pkg/providers/appsec/testdata/ase-botman.json
Original file line number Diff line number Diff line change
Expand Up @@ -3869,6 +3869,10 @@
}
}
],
"customClientSequence": [
"a7fe489d-0354-43bd-b81c-8cabbe850cdd",
"60374346-2d1d-444d-91c1-90373e3f804a"
],
"customDefinedBots": [
{
"botId": "50789280-ba99-4f8f-b4c6-ad9c1c69569a",
Expand Down
1 change: 1 addition & 0 deletions pkg/providers/appsec/testdata/ase-botman/appsec-import.sh
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ terraform import module.security.akamai_botman_custom_defined_bot.bot_a_50789280
terraform import module.security.akamai_botman_custom_defined_bot.bot_b_da1de35e-deda-4273-933d-3131291fa3d4 79947:da1de35e-deda-4273-933d-3131291fa3d4
terraform import module.security.akamai_botman_custom_client.custom_client_a_a7fe489d-0354-43bd-b81c-8cabbe850cdd 79947:a7fe489d-0354-43bd-b81c-8cabbe850cdd
terraform import module.security.akamai_botman_custom_client.custom_client_b_60374346-2d1d-444d-91c1-90373e3f804a 79947:60374346-2d1d-444d-91c1-90373e3f804a
terraform import module.security.akamai_botman_custom_client_sequence.sequence 79947
terraform import module.security.akamai_botman_serve_alternate_action.serve_alternate_action_a_action_A 79947:action_A
terraform import module.security.akamai_botman_serve_alternate_action.serve_alternate_action_b_action_B 79947:action_B
terraform import module.security.akamai_botman_challenge_action.challenge_action_a_action_A 79947:action_A
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,10 @@ resource "akamai_botman_custom_client" "custom_client_b_60374346-2d1d-444d-91c1-
)
}

resource "akamai_botman_custom_client_sequence" "sequence" {
config_id = akamai_appsec_configuration.config.config_id
custom_client_ids = [
akamai_botman_custom_client.custom_client_a_a7fe489d-0354-43bd-b81c-8cabbe850cdd.custom_client_id,
akamai_botman_custom_client.custom_client_b_60374346-2d1d-444d-91c1-90373e3f804a.custom_client_id
]
}
Loading