Skip to content

Commit

Permalink
[stack-deploy] Add propagate at launch tag handling
Browse files Browse the repository at this point in the history
* It'll add `PropagateAtLaunch=True` for all instances of ASG tags we are adding.
* I do at this point not think we need to make this configurable.
  • Loading branch information
mbj committed Nov 20, 2023
1 parent 2d16113 commit 93f7b59
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 10 deletions.
2 changes: 1 addition & 1 deletion aws-secrets/test/stack-9.4-dependencies.txt
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ socks 0.6.1
source-constraints 0.0.5
split 0.2.3.5
splitmix 0.1.0.5
stack-deploy 0.0.8
stack-deploy 0.0.9
stm 2.5.1.0
stratosphere 1.0.0
stratosphere-ecs 1.0.0
Expand Down
2 changes: 1 addition & 1 deletion aws-secrets/test/stack-9.6-dependencies.txt
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ socks 0.6.1
source-constraints 0.0.5
split 0.2.4
splitmix 0.1.0.5
stack-deploy 0.0.8
stack-deploy 0.0.9
stm 2.5.1.0
stratosphere 1.0.0
stratosphere-ecs 1.0.0
Expand Down
2 changes: 1 addition & 1 deletion aws-temporary-ingress-rule/test/stack-9.4-dependencies.txt
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ socks 0.6.1
source-constraints 0.0.5
split 0.2.3.5
splitmix 0.1.0.5
stack-deploy 0.0.8
stack-deploy 0.0.9
stm 2.5.1.0
stratosphere 1.0.0
stratosphere-ecs 1.0.0
Expand Down
2 changes: 1 addition & 1 deletion aws-temporary-ingress-rule/test/stack-9.6-dependencies.txt
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ socks 0.6.1
source-constraints 0.0.5
split 0.2.4
splitmix 0.1.0.5
stack-deploy 0.0.8
stack-deploy 0.0.9
stm 2.5.1.0
stratosphere 1.0.0
stratosphere-ecs 1.0.0
Expand Down
2 changes: 1 addition & 1 deletion stack-deploy/package.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
_common/package: !include "../common/package.yaml"

name: stack-deploy
version: 0.0.8
version: 0.0.9
synopsis: Utilities around cloudformation templates
license: BSD3

Expand Down
19 changes: 16 additions & 3 deletions stack-deploy/src/StackDeploy/InstanceSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,24 @@ addResourcePropertiesTags tags Stratosphere.ResourceProperties{..}
, ..
}
where
addPropagateAtLaunch value =
if awsType == "AWS::AutoScaling::AutoScalingGroup"
then mergeArrayObject value (JSON.Object [("PropagateAtLaunch", JSON.toJSON True)])
else value

newProperties =
if supportsTags
then KeyMap.unionWith merge [("Tags", JSON.toJSON tags)] properties
then KeyMap.unionWith mergeArray [("Tags", addPropagateAtLaunch $ JSON.toJSON tags)] properties
else properties

merge leftValue rightValue = case (leftValue, rightValue) of
mergeArrayObject leftValue rightValue = case leftValue of
JSON.Array leftItems -> JSON.Array $ mergeObject rightValue <$> leftItems
other -> error $ "invalid array merge:" <> show (other, rightValue)

mergeObject leftValue rightValue = case (leftValue, rightValue) of
(JSON.Object leftMap, JSON.Object rightMap) -> JSON.Object $ leftMap <> rightMap
other -> error $ "invalid object merge:" <> show other

mergeArray leftValue rightValue = case (leftValue, rightValue) of
(JSON.Array leftItems, JSON.Array rightItems) -> JSON.Array $ leftItems <> rightItems
other -> error $ "non tag array merge:" <> show other
other -> error $ "invalid array merge:" <> show other
2 changes: 1 addition & 1 deletion stack-deploy/stack-deploy.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cabal-version: 1.12
-- see: https://github.com/sol/hpack

name: stack-deploy
version: 0.0.8
version: 0.0.9
synopsis: Utilities around cloudformation templates
homepage: https://github.com/mbj/mhs#readme
bug-reports: https://github.com/mbj/mhs/issues
Expand Down
2 changes: 1 addition & 1 deletion stack-deploy/test/stack-9.6-dependencies.txt
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ socks 0.6.1
source-constraints 0.0.5
split 0.2.4
splitmix 0.1.0.5
stack-deploy 0.0.8
stack-deploy 0.0.9
stm 2.5.1.0
stratosphere 1.0.0
stratosphere-ecs 1.0.0
Expand Down

0 comments on commit 93f7b59

Please sign in to comment.