Skip to content
This repository has been archived by the owner on Oct 21, 2023. It is now read-only.

Commit

Permalink
Merge branch 'dev' of https://github.com/scrthq/Vaporshell
Browse files Browse the repository at this point in the history
  • Loading branch information
scrthq committed Jun 28, 2017
2 parents 649fd2d + a14d0ae commit a44724d
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 86 deletions.
93 changes: 15 additions & 78 deletions README.md
Expand Up @@ -7,29 +7,34 @@

# *Vaporshell*

Vaporshell is a module for Powershell that allows easier and less error prone build outs of AWS CloudFormation JSON templates using familiar syntax and structure to define AWS resources, while simultaneously gaining the capabilities of Powershell and removing the need to work with JSON directly.
[Vaporshell](http://vaporshell.io/) is a module for Powershell that allows easier and less error prone build outs of AWS CloudFormation JSON templates using familiar syntax and structure to define AWS resources, while simultaneously gaining the capabilities of Powershell and removing the need to work with JSON directly.

Vaporshell allows you to either initialize a new template or import an existing template, add appropriate properties and export it out to JSON.

For those that are familiar with [Troposphere for Python by CloudTools](https://github.com/cloudtools/troposphere), this aims to be an equivalent option for Powershell users.

***

### Like what's happening and want to send over some coffee money for fuel? Invoke-Donation by clicking below!

[![Donate through Paypal](http://i.imgur.com/bE5YaCm.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=GU6CJMFGVP6ZS)
[![Donate through Paypal](https://img.shields.io/badge/paypal-donate-brightgreen.svg)](https://gratipay.com/Vaporshell) [![Donate through Gratipay](https://img.shields.io/badge/paypal-donate-brightgreen.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=GU6CJMFGVP6ZS)

***

## Getting Started

<http://vaporshell.io/docs/examples>

***

## How to Install
## Module Digest

<http://vaporshell.io/docs/digest>

[![PS Gallery](https://img.shields.io/badge/install-PS%20Gallery-blue.svg)](https://www.powershellgallery.com/packages/Vaporshell)
***

You can install the module directly from [Powershell Gallery](https://www.powershellgallery.com/packages/vaporshell) by running the following command in and administrator Powershell console:
## Examples

`Install-Module -Name Vaporshell`
<http://vaporshell.io/docs/examples>

NOTE: This requires the PowerShellGet module. This comes standard for Windows 10, Linux and MacOS users that have Powershell, but may require installation for other OS's. [Please check out Getting Started with the Gallery](https://www.powershellgallery.com/) for more info.

***

Expand All @@ -45,72 +50,4 @@ This module is only to be used to ease creation of CloudFormation templates. Any

If you find any oddities with the template build, please open an issue here on GitHub and include your script with sensitive data redacted, what you were expecting it to add to the template and what actually was added.

Thanks!

***

## Examples
_Full documentation is being prepared right now._

```powershell
$templateInit = $null
$templateInit = Initialize-Vaporshell -Description "Testing"
$templateInit.AddMetadata((New-VaporMetadata -LogicalId "Instances" -Metadata @{"Description" = "Information about the instances"}))
$templateInit.AddCondition(
(New-VaporCondition -LogicalId "CreateProdResources" -Condition (Add-ConEquals -FirstValue (Add-FnRef -Ref "EnvType") -SecondValue "prod")),
(Add-Include -Location "s3://MyAmazonS3BucketName/single_wait_condition.yaml")
)
$templateInit.AddMapping(
(New-VaporMapping -LogicalId "RegionMap" -Map ([PSCustomObject][Ordered]@{
"us-east-1" = [PSCustomObject][Ordered]@{
"32" = "ami-6411e20d"
"64" = "ami-7a11e213"
}
"us-west-1" = [PSCustomObject][Ordered]@{
"32" = "ami-c9c7978c"
"64" = "ami-cfc7978a"
}
})
)
)
$templateInit.AddResource(
(New-VaporResource -LogicalId "MyInstance" -Type "AWS::EC2::Instance" -Properties ([PSCustomObject][Ordered]@{
"UserData" = (Add-FnBase64 -ValueToEncode (Add-FnJoin -ListOfValues "Queue=",(Add-FnRef -Ref "MyQueue")))
"AvailabilityZone" = "us-east-1a"
"ImageId" = (Add-FnFindInMap -MapName "RegionMap" -TopLevelKey "$_AWSRegion" -SecondLevelKey "32")
})
)
)
$templateInit.AddOutput((New-VaporOutput -LogicalId "BackupLoadBalancerDNSName" -Description "The DNSName of the backup load balancer" -Value (Add-FnGetAtt -LogicalNameOfResource "BackupLoadBalancer" -AttributeName "DNSName") -Condition "CreateProdResources"))
# Export the initial Template object to JSON
$testPath = "$($PSScriptRoot)\test.json"
Export-Vaporshell -VaporshellTemplate $templateInit -Path $testPath -Force
# Import a template file and add new properties to the template
$template = Import-Vaporshell -Path $testPath
$template.AddMetadata((New-VaporMetadata -LogicalId "Databases" -Metadata @{"Description" = "Information about the Databases"}))
$template.AddCondition((New-VaporCondition -LogicalId "CreateTestResources" -Condition (Add-ConEquals -FirstValue (Add-FnRef -Ref "EnvType") -SecondValue "test")))
$template.AddMapping(
(New-VaporMapping -LogicalId "RegionMap2" -Map ([PSCustomObject][Ordered]@{
"us-east-2" = [PSCustomObject][Ordered]@{
"32" = "ami-6411e20d"
"64" = "ami-7a11e213"
}
"us-west-2" = [PSCustomObject][Ordered]@{
"32" = "ami-c9c7978c"
"64" = "ami-cfc7978a"
}
})
)
)
$template.AddResource(
(New-VaporResource -LogicalId "MyInstance2" -Type "AWS::EC2::Instance" -Properties ([PSCustomObject][Ordered]@{
"UserData" = (Add-FnBase64 -ValueToEncode (Add-FnJoin -ListOfValues "Queue=",(Add-FnRef -Ref "MyQueue")))
"AvailabilityZone" = "us-east-1b"
"ImageId" = (Add-FnFindInMap -MapName "RegionMap" -TopLevelKey "$_AWSRegion" -SecondLevelKey "32")
})
)
)
$template.AddOutput((New-VaporOutput -LogicalId "PrimaryLoadBalancerDNSName" -Description "The DNSName of the primary load balancer" -Value (Add-FnGetAtt -LogicalNameOfResource "PrimaryLoadBalancer" -AttributeName "DNSName") -Condition "CreateTestResources"))
```
Thanks!
11 changes: 10 additions & 1 deletion Vaporshell/Public/Import-Vaporshell.ps1
Expand Up @@ -24,7 +24,16 @@ function Import-Vaporshell {
[String]
$Path
)
$tempObj = Get-Content $Path -Verbose:$false | ConvertFrom-Json -Verbose:$false
$temp = Get-Content $Path -Verbose:$false
if ($temp -contains "Resources:") {
if (Get-Command cfn-flip -ErrorAction SilentlyContinue) {
$temp = cfn-flip $Path
}
else {
throw "Template appears to be YAML but cfn-flip is not found in PATH. Unable to convert to JSON to import into Powershell. Please install cfn-flip then restart this console."
}
}
$tempObj = $temp | ConvertFrom-Json -Verbose:$false
$addMetadata = {
Process {
$ObjName = "Metadata"
Expand Down
29 changes: 23 additions & 6 deletions Vaporshell/Vaporshell.psd1
Expand Up @@ -12,7 +12,7 @@
RootModule = 'Vaporshell.psm1'

# Version number of this module.
ModuleVersion = '0.7.1'
ModuleVersion = '1.0.0'

# ID used to uniquely identify this module
GUID = 'd526494c-6e59-41ff-ad05-eedbc1473b6a'
Expand All @@ -27,9 +27,26 @@
Copyright = '(c) SCRT HQ 2017 . All rights reserved.'

# Description of the functionality provided by this module
Description = 'Powershell module for building AWS CloudFormation JSON templates using Powershell syntax, abstracting working with JSON, etc. Essentially a Powershell equivalent to Troposphere for Python.
Description = 'Powershell module for building AWS CloudFormation JSON templates using Powershell syntax, abstracting working with JSON, etc.
Requires Powershell version 3.0 or higher, as it leverages ConvertTo-Json and ConvertFrom-Json to work with the template files.'
Requires Powershell version 3.0 or higher, as it leverages ConvertTo-Json and ConvertFrom-Json to work with the template files.
## Getting Started
<http://vaporshell.io/docs/examples>
***
## Module Digest
<http://vaporshell.io/docs/digest>
***
## Examples
<http://vaporshell.io/docs/examples>'

# Minimum version of the Windows PowerShell engine required by this module
PowerShellVersion = '3.0'
Expand Down Expand Up @@ -94,13 +111,13 @@ Requires Powershell version 3.0 or higher, as it leverages ConvertTo-Json and Co
PSData = @{

# Tags applied to this module. These help with module discovery in online galleries.
Tags = 'AWS','CloudFormation','CFN','JSON'
Tags = 'AWS','CloudFormation','CFN','JSON','YAML'

# A URL to the license for this module.
# LicenseUri = ''

# A URL to the main website for this project.
ProjectUri = 'https://github.com/nferrell/Vaporshell'
ProjectUri = 'http://vaporshell.io'

# A URL to an icon representing this module.
IconUri = 'https://spotinst.com/app/themes/spotinst-theme/dist/images/features/elastigroup/intro/icons/cloudformation.svg'
Expand All @@ -116,7 +133,7 @@ Requires Powershell version 3.0 or higher, as it leverages ConvertTo-Json and Co
} # End of PrivateData hashtable

# HelpInfo URI of this module
HelpInfoURI = 'https://github.com/nferrell/Vaporshell/wiki'
HelpInfoURI = 'http://vaporshell.io/docs/'

# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = ''
Expand Down
3 changes: 2 additions & 1 deletion psake.ps1
Expand Up @@ -68,7 +68,8 @@ Task Build -Depends Test {

# Bump the module version
$Version = Get-NextPSGalleryVersion -Name $env:BHProjectName
Update-Metadata -Path $env:BHPSModuleManifest -PropertyName ModuleVersion -Value $Version
Update-Metadata -Path $env:BHPSModuleManifest -PropertyName ModuleVersion -Value "1.0.0" #$Version

#Update-Metadata -Path $env:BHPSModuleManifest -Increment Build
}

Expand Down

0 comments on commit a44724d

Please sign in to comment.