Skip to main content
⏳ Estimated read time: 2 min read
Important

You will need a StackGen Admin or DevOps access to run this command.

resource-override-policy

The stackgen upload resource-override-policy command allows you to upload custom resource override and mapping policies that automatically modify resource types or enforce specific templates, ensuring consistency and compliance across your infrastructure.

Supported Clouds

All cloud providers.

Usage

stackgen upload resource-override-policy [flags]

Flags

FlagDescription
-p, --override-policy-file-path stringPath to override and mapping policy file.
-h, --helpHelp for resource-override-policy.

Examples

Upload resource override policy from a local file

stackgen upload resource-override-policy -p /path/to/resource_override_policy.json

This command will:

  • Read the override policy from the specified JSON file,
  • Upload the policy to the StackGen platform,
  • Automatically apply these overrides to matching resources in your topologies.

File Format

The resource override policy file should be in JSON format and define resource type mappings and overrides to apply. Here's an example:

[
{
"Name": "ImportedTestPolicy",
"OverrideResourceTypeDetails": {
"aws_s3": {
"OverrideType": "aws_s3_bucket",
"Locked": true,
"TemplateID": "some-template-id"
},
"helm_postgresql": {
"OverrideType": "aws_rds",
"Locked": true,
"TemplateID": "helm"
}
}
}
]

Each policy object in the array must include:

  • Name: A unique identifier for the policy.
  • OverrideResourceTypeDetails: A map of resource types to their override configurations
    • Key: The original resource type.
    • Value: The override details containing:
      • OverrideType: The target resource type to use instead.
      • Locked: Boolean indicating if this override is mandatory.
      • TemplateID: ID of a template to use for this resource.
note
  • For tfstate and tfplan imports, refer to terraform resource types for mapping and override:
  • Override policies are useful for enforcing organization standards and resource mappings.
  • These policies are applied automatically during resource creation or modification.

Check out the How-to article How Do I Enforce Default Custom Module Usage Via Resource Override Policies.