mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 22:11:36 -05:00
fix(cloudformation): resolve changeset by ARN in DescribeChangeSet, ExecuteChangeSet, DeleteChangeSet (#608)
The AWS CLI's passes the full changeset ARN (returned by CreateChangeSet) as the ChangeSetName parameter to subsequent calls. CloudFormationService was doing a direct map lookup by the raw parameter value, which always missed because changesets are stored by short name — causing a 400 ChangeSetNotFoundException and the CLI to crash with . Add resolveChangeSetName() to extract the short name from an ARN before the map lookup, and apply it in describeChangeSet, executeChangeSet, and deleteChangeSet. Closes #606 Co-authored-by: Dixit R Jain <dixitrjain@Mac-1319.lan>
This commit is contained in:
1 parent
2dfb4fc248
commit
7592151cb6
3 files changed
+222
-4
No files matched your search
+21
-4
@@ -100,7 +100,7 @@ public class CloudFormationService {
|
||||
|
||||
public ChangeSet describeChangeSet(String stackName, String changeSetName, String region) {
|
||||
Stack stack = getStackOrThrow(stackName, region);
|
||||
ChangeSet cs = stack.getChangeSets().get(changeSetName);
|
||||
ChangeSet cs = stack.getChangeSets().get(resolveChangeSetName(changeSetName));
|
||||
if (cs == null) {
|
||||
throw new AwsException("ChangeSetNotFoundException",
|
||||
"ChangeSet [" + changeSetName + "] does not exist", 400);
|
||||
@@ -112,7 +112,7 @@ public class CloudFormationService {
|
||||
|
||||
public Future<?> executeChangeSet(String stackName, String changeSetName, String region) {
|
||||
Stack stack = getStackOrThrow(stackName, region);
|
||||
ChangeSet cs = stack.getChangeSets().get(changeSetName);
|
||||
ChangeSet cs = stack.getChangeSets().get(resolveChangeSetName(changeSetName));
|
||||
if (cs == null) {
|
||||
throw new AwsException("ChangeSetNotFoundException",
|
||||
"ChangeSet [" + changeSetName + "] does not exist", 400);
|
||||
@@ -136,12 +136,13 @@ public class CloudFormationService {
|
||||
|
||||
public void deleteChangeSet(String stackName, String changeSetName, String region) {
|
||||
Stack stack = getStackOrThrow(stackName, region);
|
||||
ChangeSet cs = stack.getChangeSets().get(changeSetName);
|
||||
String name = resolveChangeSetName(changeSetName);
|
||||
ChangeSet cs = stack.getChangeSets().get(name);
|
||||
if (cs == null) {
|
||||
throw new AwsException("ChangeSetNotFoundException",
|
||||
"ChangeSet [" + changeSetName + "] does not exist", 400);
|
||||
}
|
||||
stack.getChangeSets().remove(changeSetName);
|
||||
stack.getChangeSets().remove(name);
|
||||
}
|
||||
|
||||
// ── DeleteStack ───────────────────────────────────────────────────────────
|
||||
@@ -493,6 +494,22 @@ public class CloudFormationService {
|
||||
return stack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves a changeset name from either a short name or a full ARN.
|
||||
* The AWS CLI passes the full ARN (arn:aws:cloudformation:…:changeSet/<name>/<uuid>)
|
||||
* when referencing a changeset by the ID returned from CreateChangeSet.
|
||||
*/
|
||||
private String resolveChangeSetName(String changeSetNameOrArn) {
|
||||
if (changeSetNameOrArn != null && changeSetNameOrArn.startsWith("arn:")) {
|
||||
// arn:aws:cloudformation:<region>:<account>:changeSet/<name>/<uuid>
|
||||
String[] parts = changeSetNameOrArn.split("/");
|
||||
if (parts.length >= 2) {
|
||||
return parts[1];
|
||||
}
|
||||
}
|
||||
return changeSetNameOrArn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves a stack by name or ARN. When an ARN is provided the stack name
|
||||
* is extracted from the ARN path segment ({@code …:stack/<name>/<id>}).
|
||||
|
||||
Reference in new issue
Block a user