Fixed #286 by forcing new a saved search resource if the name changes — copy & delete search as expected by user, but update would copy without deletion.
Fixed #181 by introducing support for updating search queries and documenting the need for the lifecycle create_before_destroy to be true.
Description
Usability improvements around updating saved search name and updating the the underlying query.
Motivation and Context
The provider doesn't behave as expected.
How Has This Been Tested?
Used the script and module below to test various state changes.
#!/usr/bin/env zsh
outpath="$PWD/test-286.out"
mkdir -pv "$outpath" || exit 1
find "$outpath" -type f -exec rm {} \;
export TF_LOG=INFO
pushd "$HOME/repo/terraform-provider-prismacloud"
goreleaser build --clean --single-target --snapshot || exit 1
find dist -name 'terraform-provider-prismacloud_v1.5.5*' -execdir mv -f {} "$HOME/.terraform.d/plugins/terraform.local/comrumino/prismacloud/1.5.5/darwin_arm64/terraform-provider-prismacloud_v1.5.5" \;
popd
rm -rf "$PWD/.terraform/providers/terraform.local" "$PWD/.terraform.lock.hcl"
terraform init
function apply_with_name() {
local name="$1"
local query="$2"
printf '{"saved_search_name":"%s","query":"%s"}' "$name" "$query" | jq -r . > "$PWD/terraform.tfvars.json"
terraform graph -draw-cycles -type=plan | dot -Tpng > "$outpath/$name-graph.png"
TF_LOG_PATH="$outpath/$name-apply-tf.log" terraform apply -var saved_search_name="$name" -auto-approve &>> "$outpath/stdout-$name-apply-tf.log"
}
apply_with_name "prototype" "config from cloud.resource where api.name = 'aws-guardduty-detector' AND json.rule = status equals \\\"ENABLED\\\""
apply_with_name "prototype" "config from cloud.resource where api.name = 'aws-guardduty-detector' AND json.rule = status equals \\\"DISABLED\\\""
apply_with_name "prototype2" "config from cloud.resource where api.name = 'aws-guardduty-detector' AND json.rule = status equals \\\"DISABLED\\\""
TF_LOG_PATH="$outpath/destroy-tf.log" terraform destroy -auto-approve &> "$outpath/stdout-destroy-tf.log"
printf '\n\nLogged to %s\n' "$outpath"
Description
Usability improvements around updating saved search name and updating the the underlying query.
Motivation and Context
The provider doesn't behave as expected.
How Has This Been Tested?
Used the script and module below to test various state changes.
Types of changes
Checklist