Skip to main content

Workload Parameters

Stax Workloads utilizes parameters that can be passed to Cloudformation templates. There are different parameters that can be manually specified or Stax default parameters which get passed at the time of deployment. On this page we will go through each type of parameter supported by Stax Workloads and how they can be used.

Manifest Parameters

Parameters defined in the Stax Manifest will be passed directly to the Cloudformation template. The values set here are static and will override any other value of the same name everytime the Workload is deployed. If you require different values to be passed for each deployment it is suggested to add the values at deployment time instead of in the Manifest.

Resources:
- S3Bucket:
Type: AWS::Cloudformation
TemplateURL: s3://example-artifactbucket/cloudformation/s3.yml
Parameters:
BucketName: my-s3-bucket
BucketDeletionPolicy: Retain

Passing Parameters Between Cloudformation Templates

When the Workload Manifest references more than one resource, CloudFormation output parameters are passed to all subsequent CloudFormation templates. Those CloudFormation templates can then consume these parameters. Parameters are passed to all subsequent templates, so it is important to consider naming uniqueness when utilizing CloudFormation parameters and Stax Workloads.

The example below shows a Workloads Manifest with two CloudFormation templates. The S3BucketName output from the first template is passed to a parameter in the next CloudFormation template.

Output names emitted from a CloudFormation template must match the input parameter names in the next template.

Manifest

Resources:
- S3Bucket:
Type: AWS::Cloudformation
TemplateURL: s3://example-artifactbucket/cloudformation/s3.yml
- SSMParameter:
Type: AWS::Cloudformation
TemplateURL: s3://example-artifactbucket/cloudformation/ssm.yml

s3.yml

AWSTemplateFormatVersion: "2010-09-09"
Resources:
S3Bucket:
Type: "AWS::S3::Bucket"
Properties:
BucketName: "my-s3-bucket"
Outputs:
S3BucketName:
Value: !Ref S3Bucket

ssm.yml

AWSTemplateFormatVersion: "2010-09-09"
Parameters:
S3BucketName:
Type: String
Resources:
Parameter:
Type: "AWS::SSM::Parameter"
Properties:
Name: "/config/bucketName"
Type: "String"
Value: !Ref S3BucketName

Stax Default Parameters

The following Stax default parameters are available to all workloads. They are passed to the CloudFormation template at deployment time.

  • StaxAccountId

  • StaxAwsAccountId

  • StaxOrgAlias

  • StaxOrgId

  • StaxAwsOrgId

  • StaxServiceName

  • StaxWorkloadId

  • StaxWorkloadName

The below example shows the use of the Stax inbuilt parameters. The Manifest file does not require the parameters to be specified.

Manifest

Resources:
- S3Bucket:
Type: AWS::Cloudformation
TemplateURL: s3://example-artifactbucket/cloudformation/s3.yml

CloudFormation Template

AWSTemplateFormatVersion: "2010-09-09"
Parameters:
StaxOrgAlias:
Type: "String"
StaxWorkloadName:
Type: "String"
Resources:
S3Bucket:
Type: "AWS::S3::Bucket"
Properties:
BucketName: !Sub "${StaxOrgAlias}-${StaxWorkloadName}"

Parameter Precedence

Since parameters can be set in multiple places, Stax Workloads loads all of these parameters and then chooses which parameter to use based on parameter precedence. Different Workload Parameters will override each other depending on where they are specified.

Here is the order in which parameters with the same name will be applied. Precedence order is listed below, 1 will get applied first with the last in the list overriding all other parameters with the same name

  1. Cloudformation template default value parameters

  2. Stax Default Parameters

  3. Parameters specified in the Stax Workload Manifest

  4. Parameters passed at Workload deployment time via the API or Stax Console

  5. Cloudformation Output Parameters