@macro

Extend the functionality of your Architect app with standard CloudFormation. The @macro primitive allows developers to add any resources or modify existing ones extending Architect into the entire AWS ecosystem supported by CloudFormation. Macros also allow you to look for custom directives and add pre-deploy steps. You can find some examples in our GitHub.

Getting started

These example configuration files declare a macro saved to src/macros/my-custom-macro.js

arc
@app
testapp

@macros
my-custom-macro
json
{
  "app": "testapp",
  "macros": [
    "my-custom-macro"
  ]
}
toml
app="testapp"

macros=[
 "my-custom-macro"
]

yaml
---
app: testapp

macros:
- my-custom-macro

Deploy

When running arc deploy Architect looks for macros to run in:

  • src/macros/filename
  • node_modules/macro-module-name

You deploy a macro by using this syntax:

  • arc deploy to deploy with CloudFormation to staging
  • arc deploy production to run a full CloudFormation production deployment

Examples

Macros receive the parsed app.arc file so custom pragmas and config can be defined. The second argument is the current CloudFormation template.

/**
 * @param {object} arc - the parsed app.arc file currently executing
 * @param {object} cloudformation - the current AWS::Serverless CloudFormation template
 * @param {object} stage - the application stage (one of `staging` or `production`)
 * @returns {object|Promise} must return a CloudFormation object or a promise for a CloudFormation object
 **/
module.exports = function myCustomMacro(arc, cloudformation, stage) {
  // modify cloudformation.Resources here
  return cloudformation
}

Note: macros are a new feature and only JavaScript macros are supported at this time; however Python and Ruby are planned