Skip to content

[AWSCORE-694] mock AWS provider in all tests for CI readiness#33

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 11 commits into
mainfrom
kyle.harris/AWSCORE-694-mock-providers
Mar 13, 2026
Merged

[AWSCORE-694] mock AWS provider in all tests for CI readiness#33
gh-worker-dd-mergequeue-cf854d[bot] merged 11 commits into
mainfrom
kyle.harris/AWSCORE-694-mock-providers

Conversation

@ksirrah13

@ksirrah13 ksirrah13 commented Mar 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Convert all test files from provider "aws" to mock_provider "aws" so tests run without AWS credentials
  • Convert command = apply to command = plan since mock providers don't need real resource creation
  • Adapt assertions for plan-time behavior (null checks instead of key absence checks)
  • Mark dd_api_key_secret_arn output as sensitive (required by mock provider treating secretsmanager ARNs as sensitive)
  • Add dedicated secrets_management.tftest.hcl covering all API key configuration paths:
    • Auto-create secret from dd_api_key (default path)
    • External dd_api_key_secret_arn provided
    • SSM parameter via dd_api_key_ssm_parameter_name
    • Explicit create_dd_api_key_secret = false with external ARN
  • Update default_config.tftest.hcl to test true defaults (no dd_api_key_secret_arn override)
  • All 44 tests pass across 14 test files

Context

AWSCORE-694 — This PR covers the mock provider migration and CI setup. CI setup completed in this stacked PR.
#34

Test plan

  • terraform test passes locally — 44 passed, 0 failed
  • CI pipeline (to be added in follow-up task)

@ksirrah13 ksirrah13 changed the title test: mock AWS provider in all tests for CI readiness [AWSCORE-694] mock AWS provider in all tests for CI readiness Mar 2, 2026
Convert the remaining 6 test files from using `provider "aws"` to
`mock_provider "aws"` so tests can run without AWS credentials.

- Convert command = apply to command = plan (mock providers simulate
  resource creation without needing real AWS APIs)
- Provide dd_api_key_secret_arn explicitly to avoid computed attribute
  references that are unknown at plan time
- Replace !contains(keys()) null checks with == null assertions
  (plan-time behavior keeps null keys in the map)
- Add dedicated secrets_manager_default_test for secret creation

All 32 tests pass across 11 test files.

AWSCORE-694
@ksirrah13
ksirrah13 force-pushed the kyle.harris/AWSCORE-694-mock-providers branch from 995eb73 to 6886f87 Compare March 9, 2026 18:07
The mock provider treats secretsmanager secret ARNs as sensitive values,
causing all tests to fail with "Output refers to sensitive values" error.
@ksirrah13
ksirrah13 marked this pull request as ready for review March 9, 2026 18:13
@ksirrah13
ksirrah13 requested review from a team as code owners March 9, 2026 18:13
…ig to true defaults

Remove dd_api_key_secret_arn from default_config variables so it tests
the actual default path (auto-create secret from dd_api_key). Move all
secret management permutations to a dedicated secrets_management test
file covering auto-create, external ARN, SSM parameter, and explicit
create_dd_api_key_secret=false paths.
@ksirrah13
ksirrah13 force-pushed the kyle.harris/AWSCORE-694-mock-providers branch from f1b2b8b to b2de6ea Compare March 9, 2026 18:34
Add two CI workflows that run on pull requests:
- terraform-fmt: checks formatting with terraform fmt -recursive
- terraform-test: runs terraform test using mock providers (no AWS credentials needed)
Comment thread tests/secrets_management.tftest.hcl Outdated
command = plan

variables {
dd_api_key = "test-api-key-value"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this needed? or is part of the test showing that this value is ignored when dd_api_key_secret_arn is provided?

@ksirrah13 ksirrah13 Mar 11, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great point. It was copied from existing tests but those also seem to be wrong to be setting both the api_key and secret_arn values (even though we ignore the API key). I cleaned them all up so that if we set the arn we don't set the API key. I also added a warning that if customers are setting both right now it will only use one and they should clean it up. Thanks!

ktmq
ktmq previously approved these changes Mar 11, 2026
dd_api_key defaults to null and should not be set alongside
dd_api_key_secret_arn per the variable docs. Removing it makes the
test accurately represent the "bring your own secret" path.
- Remove dd_api_key where it conflicts with dd_api_key_secret_arn or
  dd_api_key_ssm_parameter_name (variable docs say choose ONE approach)
- Remove explicit null assignments for variables that already default
  to null (dd_api_key, dd_api_key_secret_arn)
- Remove out-of-scope S3 bucket assertion from optional_env_vars test
  (already covered by enhanced_features test)

Affected files: secrets_management, enhanced_features, optional_env_vars,
existing_resources, existing_iam_role_without_bucket
@ksirrah13
ksirrah13 requested a review from a team as a code owner March 11, 2026 14:44
Add validation rules that reject conflicting API key configurations
instead of silently ignoring one. The three approaches (dd_api_key,
dd_api_key_secret_arn, dd_api_key_ssm_parameter_name) are now mutually
exclusive at the variable level.

Add tests for all three pairwise conflict scenarios.
… conflicts

Replace variable validation blocks with check blocks that produce
warnings instead of errors. This avoids breaking existing customers
who may have multiple API key variables set. The warnings explain
which value is being ignored and that this will become a hard error
in a future release.
@ksirrah13
ksirrah13 requested a review from ktmq March 11, 2026 15:38
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit 192dbbe into main Mar 13, 2026
5 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the kyle.harris/AWSCORE-694-mock-providers branch March 13, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants