Skip to content

Commit 61167a0

Browse files
committed
fix: support ints within schema for AWS::EC2::AutoscalingGroup
1 parent 75e8505 commit 61167a0

File tree

1 file changed

+14
-21
lines changed

1 file changed

+14
-21
lines changed

bin/clover/src/pipelines/aws/funcs/overrides/AWS::AutoScaling::AutoScalingGroup/actions/awsCloudControlUpdate.ts

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,6 @@ async function main(component: Input): Promise<Output> {
7878
resourceResponse["ResourceDescription"]["Properties"],
7979
);
8080

81-
// Convert string properties that should be integers to numbers
82-
const integerProps = ["MaxSize", "MinSize", "Cooldown", "DesiredCapacity"];
83-
integerProps.forEach(propName => {
84-
if (currentState[propName] && typeof currentState[propName] === "string") {
85-
const numValue = parseInt(currentState[propName], 10);
86-
if (!isNaN(numValue)) {
87-
currentState[propName] = numValue;
88-
console.log(`[ASG-UPDATE] Converted currentState.${propName} from "${currentState[propName]}" to ${numValue}`);
89-
}
90-
}
91-
});
92-
9381
const desiredProps = JSON.parse(
9482
component.properties.code?.["awsCloudControlUpdate"]?.code,
9583
)?.DesiredState;
@@ -101,27 +89,31 @@ async function main(component: Input): Promise<Output> {
10189

10290
addSecretsToPayload(desiredProps, propUsageMap);
10391

104-
// Also convert integer properties in desiredProps to ensure consistency
92+
// Keep patch operations using strings to match AWS CloudControl expectations
93+
// Convert integer properties in desiredProps to strings if AWS returns strings
94+
const integerProps = ["MaxSize", "MinSize", "Cooldown", "DesiredCapacity"];
10595
integerProps.forEach(propName => {
106-
if (desiredProps[propName] && typeof desiredProps[propName] === "string") {
107-
const numValue = parseInt(desiredProps[propName], 10);
108-
if (!isNaN(numValue)) {
109-
desiredProps[propName] = numValue;
110-
console.log(`[ASG-UPDATE] Converted desiredProps.${propName} from "${desiredProps[propName]}" to ${numValue}`);
96+
if (desiredProps[propName] !== undefined) {
97+
// If AWS returns string and desired is number, convert desired to string for patch
98+
if (typeof currentState[propName] === "string" && typeof desiredProps[propName] === "number") {
99+
desiredProps[propName] = String(desiredProps[propName]);
100+
console.log(`[ASG-UPDATE] Converted desiredProps.${propName} to string "${desiredProps[propName]}" to match AWS format`);
111101
}
102+
// If AWS returns string and desired is string, keep as string
103+
// If both are numbers, keep as numbers
112104
}
113105
});
114106

115107
const desiredState = _.cloneDeep(currentState);
116108
_.merge(desiredState, desiredProps);
117109

118-
console.log(`[ASG-UPDATE] Debug - currentState integer props:`, {
110+
console.log(`[ASG-UPDATE] Debug - patch will use currentState types:`, {
119111
MaxSize: currentState.MaxSize,
120112
MinSize: currentState.MinSize,
121113
Cooldown: currentState.Cooldown,
122114
DesiredCapacity: currentState.DesiredCapacity
123115
});
124-
console.log(`[ASG-UPDATE] Debug - desiredState integer props:`, {
116+
console.log(`[ASG-UPDATE] Debug - patch will use desiredState types:`, {
125117
MaxSize: desiredState.MaxSize,
126118
MinSize: desiredState.MinSize,
127119
Cooldown: desiredState.Cooldown,
@@ -389,7 +381,8 @@ async function main(component: Input): Promise<Output> {
389381
finalResourceResponse["ResourceDescription"]["Properties"],
390382
);
391383

392-
// Convert string properties that should be integers to numbers
384+
// Convert string properties that should be integers to numbers for final payload
385+
const integerProps = ["MaxSize", "MinSize", "Cooldown", "DesiredCapacity"];
393386
integerProps.forEach(propName => {
394387
if (payload[propName] && typeof payload[propName] === "string") {
395388
const numValue = parseInt(payload[propName], 10);

0 commit comments

Comments
 (0)