stratosphere 0.18.0 → 0.19.0
raw patch · 5 files changed
+53/−7 lines, 5 filesdep +aeson-qq
Dependencies added: aeson-qq
Files
- CHANGELOG.md +5/−0
- examples/ec2-with-eip.hs +35/−0
- library-gen/Stratosphere/Resources.hs +7/−2
- library/Stratosphere/Values.hs +3/−3
- stratosphere.cabal +3/−2
CHANGELOG.md view
@@ -1,5 +1,10 @@ # Change Log +## 0.19.0++* Fix `Equals` function requiring `Val Bool` arguments instead of `Val a`+* Add `Metadata` field to `Resource` type+ ## 0.18.0 * Update resource specification document to version 2.0.0
examples/ec2-with-eip.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE OverloadedLists #-} {-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE QuasiQuotes #-} -- | This is a translated version of an example from the CloudFormation docs at -- https://s3.amazonaws.com/cloudformation-templates-us-east-1/EIP_With_Association.template.@@ -9,6 +10,8 @@ module Main where import Control.Lens+import Data.Aeson+import Data.Aeson.QQ (aesonQQ) import qualified Data.ByteString.Lazy.Char8 as B import Stratosphere@@ -29,6 +32,7 @@ & eciSecurityGroups ?~ [Ref "InstanceSecuritygroup"] ) & resourceDeletionPolicy ?~ Retain+ & resourceMetadata ?~ ec2Metadata , resource "InstanceSecurityGroup" $ EC2SecurityGroupProperties $ ec2SecurityGroup@@ -62,6 +66,37 @@ (Ref "IPAddress") & outputDescription ?~ "IP address of the newly created EC2 instance" ]++ec2Metadata :: Object+(Object ec2Metadata) = [aesonQQ|+{+ "AWS::CloudFormation::Init": {+ "configSets": {+ "test1": ["1"],+ "test2": [{"ConfigSet": "test1"}, "2"],+ "default": [{"ConfigSet": "test2"}]+ },+ "1": {+ "commands": {+ "test": {+ "command": "echo \"$MAGIC\" > test.txt",+ "env": {"MAGIC": "I come from the environment!"},+ "cwd": "~"+ }+ }+ },+ "2": {+ "commands": {+ "test": {+ "command": "echo \"$MAGIC\" >> test.txt",+ "env": {"MAGIC": "I am test 2!"},+ "cwd": "~"+ }+ }+ }+ }+}+|] instanceTypeParam :: Parameter instanceTypeParam =
library-gen/Stratosphere/Resources.hs view
@@ -32,6 +32,7 @@ , resourceCreationPolicy , resourceUpdatePolicy , resourceDependsOn+ , resourceMetadata , ResourceProperties (..) , DeletionPolicy (..) , Resources (..)@@ -1102,6 +1103,7 @@ , _resourceCreationPolicy :: Maybe CreationPolicy , _resourceUpdatePolicy :: Maybe UpdatePolicy , _resourceDependsOn :: Maybe [T.Text]+ , _resourceMetadata :: Maybe Object } deriving (Show, Eq) instance ToRef Resource b where@@ -1120,17 +1122,19 @@ , _resourceCreationPolicy = Nothing , _resourceUpdatePolicy = Nothing , _resourceDependsOn = Nothing+ , _resourceMetadata = Nothing } $(makeLenses ''Resource) resourceToJSON :: Resource -> Value-resourceToJSON (Resource _ props dp cp up deps) =+resourceToJSON (Resource _ props dp cp up deps meta) = object $ resourcePropertiesJSON props ++ catMaybes [ maybeField "DeletionPolicy" dp , maybeField "CreationPolicy" cp , maybeField "UpdatePolicy" up , maybeField "DependsOn" deps+ , maybeField "Metadata" meta ] resourcePropertiesJSON :: ResourceProperties -> [Pair]@@ -1917,7 +1921,8 @@ cp <- o .:? "CreationPolicy" up <- o .:? "UpdatePolicy" deps <- o .:? "DependsOn"- return $ Resource n props dp cp up deps+ meta <- o .:? "Metadata"+ return $ Resource n props dp cp up deps meta -- | Wrapper around a list of 'Resources's to we can modify the aeson -- instances.
library/Stratosphere/Values.hs view
@@ -41,7 +41,7 @@ | Ref Text | If Text (Val a) (Val a) | And (Val Bool) (Val Bool)- | Equals (Val Bool) (Val Bool)+ | Equals (Val a) (Val a) | Or (Val Bool) (Val Bool) | GetAtt Text Text | Base64 (Val Text)@@ -63,7 +63,7 @@ toJSON (Ref r) = refToJSON r toJSON (If i x y) = mkFunc "Fn::If" [toJSON i, toJSON x, toJSON y] toJSON (And x y) = mkFunc "Fn::And" [toJSON (Bool' <$> x), toJSON (Bool' <$> y)]- toJSON (Equals x y) = mkFunc "Fn::Equals" [toJSON (Bool' <$> x), toJSON (Bool' <$> y)]+ toJSON (Equals x y) = mkFunc "Fn::Equals" [toJSON x, toJSON y] toJSON (Or x y) = mkFunc "Fn::Or" [toJSON (Bool' <$> x), toJSON (Bool' <$> y)] toJSON (GetAtt x y) = mkFunc "Fn::GetAtt" [toJSON x, toJSON y] toJSON (Base64 v) = object [("Fn::Base64", toJSON v)]@@ -95,7 +95,7 @@ [("Ref", o')] -> Ref <$> parseJSON o' [("Fn::If", o')] -> (\(i, x, y) -> If i x y) <$> parseJSON o' [("Fn::And", o')] -> (\(x, y) -> And (unBool' <$> x) (unBool' <$> y)) <$> parseJSON o'- [("Fn::Equals", o')] -> (\(x, y) -> Equals (unBool' <$> x) (unBool' <$> y)) <$> parseJSON o'+ [("Fn::Equals", o')] -> uncurry Equals <$> parseJSON o' [("Fn::Or", o')] -> (\(x, y) -> Or (unBool' <$> x) (unBool' <$> y)) <$> parseJSON o' [("Fn::GetAtt", o')] -> uncurry GetAtt <$> parseJSON o' [("Fn::Base64", o')] -> Base64 <$> parseJSON o'
stratosphere.cabal view
@@ -2,10 +2,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 114b5d0163580877c3ed207ba283b8d1fe2e14c76ff53f37a76ae031c6862eaa+-- hash: 6ea38dbad049185fb83defe79936d44b9b198398650dea1e93e02df23c5dc45f name: stratosphere-version: 0.18.0+version: 0.19.0 synopsis: EDSL for AWS CloudFormation description: EDSL for AWS CloudFormation category: AWS, Cloud@@ -891,6 +891,7 @@ build-depends: aeson >=0.11 , aeson-pretty >=0.8+ , aeson-qq , base >=4.8 && <5 , bytestring , containers