From f50bc63e0a3788684ece34c31858e3648c45578b Mon Sep 17 00:00:00 2001 From: Markus Schirp Date: Mon, 20 Nov 2023 23:18:22 +0000 Subject: [PATCH] [stack-deploy] Add propagate at launch tag handling * 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. --- aws-secrets/test/stack-9.4-dependencies.txt | 2 +- aws-secrets/test/stack-9.6-dependencies.txt | 2 +- .../test/stack-9.4-dependencies.txt | 2 +- .../test/stack-9.6-dependencies.txt | 2 +- stack-deploy/package.yaml | 2 +- stack-deploy/src/StackDeploy/InstanceSpec.hs | 19 ++++++++++++++++--- stack-deploy/stack-deploy.cabal | 2 +- stack-deploy/test/stack-9.4-dependencies.txt | 2 +- stack-deploy/test/stack-9.6-dependencies.txt | 2 +- 9 files changed, 24 insertions(+), 11 deletions(-) diff --git a/aws-secrets/test/stack-9.4-dependencies.txt b/aws-secrets/test/stack-9.4-dependencies.txt index 3626eb71..1fe657cd 100644 --- a/aws-secrets/test/stack-9.4-dependencies.txt +++ b/aws-secrets/test/stack-9.4-dependencies.txt @@ -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 diff --git a/aws-secrets/test/stack-9.6-dependencies.txt b/aws-secrets/test/stack-9.6-dependencies.txt index 01440e33..1dc44d95 100644 --- a/aws-secrets/test/stack-9.6-dependencies.txt +++ b/aws-secrets/test/stack-9.6-dependencies.txt @@ -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 diff --git a/aws-temporary-ingress-rule/test/stack-9.4-dependencies.txt b/aws-temporary-ingress-rule/test/stack-9.4-dependencies.txt index 3c53d178..c0d69697 100644 --- a/aws-temporary-ingress-rule/test/stack-9.4-dependencies.txt +++ b/aws-temporary-ingress-rule/test/stack-9.4-dependencies.txt @@ -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 diff --git a/aws-temporary-ingress-rule/test/stack-9.6-dependencies.txt b/aws-temporary-ingress-rule/test/stack-9.6-dependencies.txt index 6c8f4cc3..b2e7edbf 100644 --- a/aws-temporary-ingress-rule/test/stack-9.6-dependencies.txt +++ b/aws-temporary-ingress-rule/test/stack-9.6-dependencies.txt @@ -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 diff --git a/stack-deploy/package.yaml b/stack-deploy/package.yaml index 376d8a4d..774f3cb0 100644 --- a/stack-deploy/package.yaml +++ b/stack-deploy/package.yaml @@ -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 diff --git a/stack-deploy/src/StackDeploy/InstanceSpec.hs b/stack-deploy/src/StackDeploy/InstanceSpec.hs index c288d4d3..6eca50c8 100644 --- a/stack-deploy/src/StackDeploy/InstanceSpec.hs +++ b/stack-deploy/src/StackDeploy/InstanceSpec.hs @@ -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 diff --git a/stack-deploy/stack-deploy.cabal b/stack-deploy/stack-deploy.cabal index 2e448908..56f8dcbe 100644 --- a/stack-deploy/stack-deploy.cabal +++ b/stack-deploy/stack-deploy.cabal @@ -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 diff --git a/stack-deploy/test/stack-9.4-dependencies.txt b/stack-deploy/test/stack-9.4-dependencies.txt index 355ce950..bb9f9fd2 100644 --- a/stack-deploy/test/stack-9.4-dependencies.txt +++ b/stack-deploy/test/stack-9.4-dependencies.txt @@ -160,7 +160,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 diff --git a/stack-deploy/test/stack-9.6-dependencies.txt b/stack-deploy/test/stack-9.6-dependencies.txt index 83c5a497..bfd46e3c 100644 --- a/stack-deploy/test/stack-9.6-dependencies.txt +++ b/stack-deploy/test/stack-9.6-dependencies.txt @@ -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