Skip to content

Commit

Permalink
tests(aws): Add default test for aws
Browse files Browse the repository at this point in the history
  • Loading branch information
connorbrown-db committed Nov 27, 2024
1 parent 8f0f581 commit fec1eb1
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions aws/tf/tests/mock_plan.tftest.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# ---------------
# Mock providers
# ---------------
mock_provider "aws" {
# This is used because the mocked data is a random string instead of JSON, causing downstream dependencies to fail.
# This block overrides the "json" output of ALL aws_iam_policy_document data blocks to use a JSON encoded string.
mock_data "aws_iam_policy_document" {
defaults = {
json = "{\"some_fake\":\"json\"}"
}
}
# This is used to return valid zone names for the us-west-2 zone instead of the random strings that Terraform will
# generate for mocked tests. Not using this will cause the data block to create an empty list of strings.
mock_data "aws_availability_zones" {
defaults = {
names = ["us-west-2a", "us-west-2b", "us-west-2c", "us-west-2d"]
}
}
}

# A mocked databricks provider is added here so that the alias requirement can be met
mock_provider "databricks" {
alias = "mws"
}
# ---------------

# ---------------
# Variables
# ---------------
# The variables block below provides variable values for the SRA module directly, NOT the configuration that is found in
# this directory (aws-gov/tf). This is because the module call in sra.tf contains values that must be overwritten by the
# user of SRA. Calling the module directly allows us to provide these values as variables instead.
#
# Note that the below values were generated by AI, and are not real values.

variables {
aws_account_id = "123456789012"
client_id = "your-client-id"
client_secret = "your-client-secret"
databricks_account_id = "databricks-account-id"
region = "us-west-2"
resource_prefix = "my-resource-prefix"
admin_user = "[email protected]"
}

# ---------------
# Tests
# ---------------
# This runs a plan command on the module directly
run "plan_test" {
command = plan
}
# ---------------

0 comments on commit fec1eb1

Please sign in to comment.