diff --git a/Sources/App/ASG/ASGClient.swift b/Sources/App/ASG/ASGClient.swift index 9d28f97..794626b 100644 --- a/Sources/App/ASG/ASGClient.swift +++ b/Sources/App/ASG/ASGClient.swift @@ -18,7 +18,7 @@ struct ASGClient: ASGClientRepresentable { let updatedTags = tags.map { AutoScaling.Tag( key: $0.key, - propagateAtLaunch: $0.propagateAtLaunch ?? true, + propagateAtLaunch: $0.propagateAtLaunch, resourceId: $0.resourceId, resourceType: $0.resourceType ?? "auto-scaling-group", value: $0.value) diff --git a/Sources/App/Hulk.swift b/Sources/App/Hulk.swift index 32ca808..6d5c70a 100644 --- a/Sources/App/Hulk.swift +++ b/Sources/App/Hulk.swift @@ -44,12 +44,14 @@ struct Hulk { let tags = asgNames.reduce([AutoScaling.Tag]()) { finalResult, asg in guard let nodePool = clusterInfo.nodePools[asg.0] else { return finalResult } - let allTags = clusterInfo.commonTags + nodePool.tags + let allTags = (clusterInfo.commonTags ?? []) + (nodePool.tags ?? []) logger.debug("tags to add to node \(nodePool.name): \(allTags)") return finalResult + allTags.flatMap { tag in - asg.1.map { AutoScaling.Tag(key: tag.name, resourceId: $0, value: tag.value) } + asg.1.map { + AutoScaling.Tag(key: tag.name, propagateAtLaunch: tag.propagateAtLaunch, resourceId: $0, value: tag.value) + } } } diff --git a/Sources/CloudFormation/Codable/Tag+Codable.swift b/Sources/CloudFormation/Codable/Tag+Codable.swift index 9bc53b0..c6e03b2 100644 --- a/Sources/CloudFormation/Codable/Tag+Codable.swift +++ b/Sources/CloudFormation/Codable/Tag+Codable.swift @@ -5,6 +5,7 @@ extension Tag: Codable { enum CodingKeys: String, CodingKey { case name = "Name" case value = "Value" + case propagateAtLaunch = "PropagateAtLaunch" } public init(from decoder: Decoder) throws { @@ -12,7 +13,8 @@ extension Tag: Codable { self.init( name: try container.decode(String.self, forKey: .name), - value: try container.decode(String.self, forKey: .value) + value: try container.decode(String.self, forKey: .value), + propagateAtLaunch: try container.decode(Bool.self, forKey: .propagateAtLaunch) ) } diff --git a/Sources/Models/ClusterNodesTags.swift b/Sources/Models/ClusterNodesTags.swift index ab52658..52775aa 100644 --- a/Sources/Models/ClusterNodesTags.swift +++ b/Sources/Models/ClusterNodesTags.swift @@ -2,7 +2,7 @@ import Foundation public struct ClusterNodesTags { public let clusterName: String - public let commonTags: [Tag] + public let commonTags: [Tag]? public let nodePools: [NodePool] public init(clusterName: String, commonTags: [Tag], nodePools: [NodePool]) { diff --git a/Sources/Models/NodePool.swift b/Sources/Models/NodePool.swift index 21af839..bf63ae5 100644 --- a/Sources/Models/NodePool.swift +++ b/Sources/Models/NodePool.swift @@ -2,7 +2,7 @@ import Foundation public struct NodePool { public let name: String - public let tags: [Tag] + public let tags: [Tag]? public init(name: String, tags: [Tag]) { self.name = name diff --git a/Sources/Models/Tag.swift b/Sources/Models/Tag.swift index 196bf0b..8728fb4 100644 --- a/Sources/Models/Tag.swift +++ b/Sources/Models/Tag.swift @@ -3,9 +3,11 @@ import Foundation public struct Tag { public let name: String public let value: String + public let propagateAtLaunch: Bool - public init(name: String, value: String) { + public init(name: String, value: String, propagateAtLaunch: Bool) { self.name = name self.value = value + self.propagateAtLaunch = propagateAtLaunch } }