Skip to content

Easy CloudFormation deployments from PowerShell command line. Exports CloudFormation Stacks to Terraform

License

Notifications You must be signed in to change notification settings

fireflycons/PSCloudFormation

Repository files navigation

PSCloudFormation

Build status

A set of PowerShell cmdlets for manipulating AWS CloudFormation stacks, and generating Terraform configuration from existing CloudFormation stacks.

Features

  • Live display of stack events as a template is being applied when running synchronously (without -PassThru switch). Where nested stacks are involved, the events from these are also shown interleaved with those of the parent stack in chronlogical order.
  • When using a workstation with a GUI, detailed changeset information can be brought up in a browser, including an SVG graph depicting the relationships between resources that are being modifed - like terraform graph
  • Automatic packaging and upload to S3 of dependencies such as nested stack templates, lambdas, and other resources that require S3 references as described in aws cloudformation package
  • Close argument parity with similar cmdlets in AWS.Tools.CloudFormation

Experimental Features

  • Export a live CloudFormation Stack to Terraform HCL. This is sitll a work in progress, however it's still better than what you get simply by running terraform import. See Terrafom Export
    Now supports exporting nested stacks as Terraform modules.

Dependencies

This module depends on AWS.Tools version 4.1.16.0 or higher which you should install/upgrade to first

Required AWS.Tools modules:

  • AWS.Tools.CloudFormation
  • AWS.Tools.S3

New Documentation Site

Head over here for further reading and more in-depth discussion on the featues of this module.

How to Install

The module is published on the PowerShell Gallery and can be installed by following the instructions there.

Up until v3.x, there were two versions of this module published, one for Windows PowerShell and another for PowerShell Core for Linux/Mac. From now on, there is only the one module which works on all platforms.

The last version to support monolithic AWSPowerShell is v2.2.2 which can still be pulled from PSGallery.

PowerShell (Windows/Mac/Linux)

PowerShell Gallery

For non-Windows users

  • Install PowerShell on Linux (For Amazon Linux 2, follow RHEL 7 instructions).
  • Install PowerShell on Mac.

Module Cmdlets

All the cmdlets support the standard AWSPowerShell Common Credential and Region Parameters.

For full syntax and some examples, use Get-Help on the module's cmdlets.

Stack Modification Cmdlets

This module provides the following stack modification cmdlets

  • New-PSCFNStack - (Documentation) Create a new stack.
  • Update-PSCFNStack - (Documentation) Update an existing stack.
  • Remove-PSCFNStack - (Documentation) Delete one or more existing stacks.
  • Reset-PSCFNStack - (Documentation) Delete, then redeploy an existing stack.

Other Cmdlets

  • New-PSCFNChangeSet - (Documentation) Create changeset only, for review.
  • Get-PSCFNStackOutputs (Documentation) Retrieves the outputs of a stack in various useful formats for use in creation of new stack templates that will use or import these values.
  • New-PSCFNPackage (Documentation) Packages local artifacts, like aws cloudformation package.
  • Export-PSCFNTerraform (Documentation) Exports a deployed CloudFormation stack to Terraform HCL.

Template Support

Oversize templates in your local file system (file size >= 51,200 bytes) are directly supported. They will be silently uploaded to an S3 bucket which is created as necessary prior to processing with a delete after 7 days lifecycle policy to prevent buildup of rubbish. The bucket is named ps-templates-pscloudformation-region-accountid where

  • region is the region you are building the stack in, e.g. eu-west-1.
  • accountid is the numeric ID of the AWS account in which you are building the stack.

Dynamic Template Parameter Arguments

Once the CloudFormation template location is known, it is parsed in the background and everything in the Parameters block of the template is extracted and turned into cmdlet arguments. Read more here.

Notes

Thanks to

About

Easy CloudFormation deployments from PowerShell command line. Exports CloudFormation Stacks to Terraform

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published