Conditionally Referenced Resource

WARNING: This functionality is in private beta and may change in the future.


Conditionally Referenced resources enable Stackery to either provision or use an existing resource depending on the environment being deployed into. For example, a stack may use an existing AWS S3 Bucket for the “production” environment, while for development and test environments a new S3 Bucket is provisioned by Stackery.

Please see Referenced Resources for general information on using existing resources.

To conditionally use a referenced resource, first drag the resource type from the resource picker into the canvas. The resource settings defined here will be used when the resource is provisioned by Stackery. It is strongly suggested to name the resource in order to make following steps easier. Commit the new resource.

Next, Git pull the latest changes, including the new resource, to your local machine from the Stack’s repository. Open the Stackery/stack.json file. Find the definition for your new resource by searching for its name. For example, if the resource is an Object Store named “My Bucket”, it will look like the following:

{
  "id": "1234abcd",
  "name": "My Bucket",
  "publicPermissions": "none",
  "websiteHosting": false,
  "wires": [
    []
  ]
}

To reference an existing AWS S3 Bucket called “my-s3-bucket” when the Stack is deployed to the “production” environment, extend the node definition with reference information:

{
  "id": "1234abcd",
  "name": "My Bucket",
  "publicPermissions": "none",
  "websiteHosting": false,
  "wires": [
    []
  ],
  "reference": {
    "byEnvironment": {
      "production": {
        "arn": "arn:aws:s3:::my-s3-bucket"
      }
    }
  }
}

Save the new definition, commit it to your local Git repository, and push it up to your Stack’s Git repository. Now, when the stack is deployed to the “production” environment the existing S3 Bucket will be referenced. For all other environments, a new S3 Bucket will be provisioned.

Multiple environments may be specified by adding additional entries in the reference.byEnvironment map.

Try Stackery For Free

Gain control and visibility of your serverless operations from architecture design to application deployment and infrastructure monitoring.