mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
feat(cloudformation): add StackSets with account-aware provisioning (#1551)
* feat(cloudformation): add StackSets with account-aware provisioning Implement CloudFormation StackSets so a template can be deployed across target accounts and regions, and make CloudFormation provisioning land resources in the correct account. Provisioning previously ran on a background executor thread with no request scope, so the downstream service calls fell back to the default account — a stack created by account B materialised its resources under 000000000000. executeChangeSet/deleteStack now run the provisioning under a synthetic request scope bound to the deploying account (the caller's account for a single stack, the target account for a StackSet instance), mirroring the pattern other background workers already use. Single-stack resources now land in the caller's account. StackSet actions are wired through CloudFormationQueryHandler and AwsQueryController: CreateStackSet, DescribeStackSet, ListStackSets, UpdateStackSet, DeleteStackSet, CreateStackInstances, ListStackInstances, DeleteStackInstances, ListStackSetOperations. CreateStackInstances drives the existing single-stack engine once per target (account, region), provisioning each instance into that account's namespace; the stack set, its instances and its operation history live in the administration account. Tests: an integration test deploying a StackSet from an admin account into accounts B and C asserts the resources materialise in B and C and are invisible to the admin/default account, exercises describe/list/operations and instance deletion, and covers the not-found / already-exists / not-empty error paths. A single-stack test asserts resources now land in the caller's account. Design aligned with maintainers in floci-io/floci#1550. * fix(cloudformation): await StackSet instance deletion; test UpdateStackSet Make the account-scoped deleteStack overload return its Future so DeleteStackInstances completes synchronously before the operation returns, rather than racing the async resource removal. Add integration coverage for UpdateStackSet re-applying the template to existing instances. * test(cloudformation): add SDK compatibility test for StackSets Adds an sdk-test-java compatibility test exercising StackSets through the real AWS SDK CloudFormationClient (CreateStackSet, CreateStackInstances, DescribeStackSet, ListStackInstances, ListStackSetOperations, DeleteStackInstances, DeleteStackSet). It asserts the management responses unmarshal cleanly and that instances provision into each target account's namespace (verified via per-account SQS clients), per the project's policy of validating management APIs with AWS SDK clients. Runs in the compatibility CI on pull requests. * feat(cloudformation): add DescribeStackInstance and DescribeStackSetOperation Complete the StackSets API surface with the singular describe operations: DescribeStackInstance (used by orchestration that polls a single instance's status) and DescribeStackSetOperation (companion to ListStackSetOperations). Covered by the integration test and the SDK compatibility test, which confirm the StackInstance / StackSetOperation response shapes unmarshal through the real AWS SDK. * feat(cloudformation): resolve TemplateURL and report StackInstanceStatus.DetailedStatus for StackSets StackSet create/update now resolve a TemplateURL (fetched from S3) in addition to an inline TemplateBody, matching how orchestration tools reference templates staged in S3. DescribeStackInstance and ListStackInstances now also report the nested StackInstanceStatus.DetailedStatus that AWS returns and that pollers read to determine when an instance operation has completed. * feat(cloudformation): derive StackSet operation status and honor RetainStacks Address review feedback on #1551: - Operation status is now derived from instance outcomes: CreateStackInstances and UpdateStackSet report FAILED if any instance fails to deploy, instead of always SUCCEEDED. deployInstance also recognizes a rolled-back create (ROLLBACK_COMPLETE, not *_FAILED) as a failed/INOPERABLE instance, which was previously mis-reported as SUCCEEDED. - DeleteStackInstances honors RetainStacks: when true, the instance is detached from the stack set but its underlying stack and resources are left in place. - UpdateStackSet now persists the refreshed instance records. Tests: RetainStacks retention and the FAILED-operation path; docs updated. * fix(cloudformation): restore account on active scope; log StackSets test teardown Greptile review on #1551: - runUnderAccount now saves and restores the previous account ID when it runs inside an already-active request scope, so it can't leave the overridden account behind on a reused thread. (Background workers normally have no active scope, so this only hardens the synchronous-caller path.) - CloudFormationStackSetsTest teardown no longer swallows exceptions silently; it logs them, per the AGENTS.md no-empty-catch rule. * fix(cloudformation): report a failed StackSet instance delete as FAILED deleteStackInstances awaited the underlying deleteStack via a helper that swallows the failure, then removed the instance record unconditionally and hardcoded the operation status to SUCCEEDED. A failed non-retained delete was therefore reported as a success with the instance silently dropped. await() now returns whether the future completed cleanly. On a non-retained delete failure the instance record is retained (marked INOPERABLE/FAILED) and the operation status is derived via deriveOperationStatus, so it reports FAILED — matching AWS, which does not detach an instance whose stack delete failed. Adds StackSetServiceDeleteFailureTest covering the failure, success, and RetainStacks paths. * fix(cloudformation): reject templateless CreateStackSet and restore interrupt in await CreateStackSet now rejects a request with neither TemplateBody nor TemplateURL (ValidationError, matching AWS) instead of storing a null template — which would otherwise make a later CreateStackInstances deploy empty stacks into every target account. Also handle InterruptedException separately in await(Future) and restore the thread's interrupt flag, so a shutdown signal to the backing ExecutorService propagates instead of being swallowed. Adds a CreateStackSet-without-template integration test.
This commit is contained in:
1 parent
a27971c7d5
commit
058e02630a
12 files changed
+1642
-12
No files matched your search
@@ -360,7 +360,10 @@ public class AwsQueryController {
|
||||
"ListStacks", "ListExports", "GetTemplate", "ValidateTemplate",
|
||||
"CreateChangeSet", "DeleteChangeSet", "DescribeChangeSet", "ExecuteChangeSet", "ListChangeSets",
|
||||
"DescribeStackEvents", "DescribeStackResources", "ListStackResources", "DescribeStackResource",
|
||||
"SetStackPolicy", "GetStackPolicy", "ListStackSets", "DescribeStackSet", "CreateStackSet"
|
||||
"SetStackPolicy", "GetStackPolicy",
|
||||
"ListStackSets", "DescribeStackSet", "CreateStackSet", "UpdateStackSet", "DeleteStackSet",
|
||||
"CreateStackInstances", "ListStackInstances", "DescribeStackInstance", "DeleteStackInstances",
|
||||
"ListStackSetOperations", "DescribeStackSetOperation"
|
||||
);
|
||||
|
||||
private static final Set<String> SES_ACTIONS = Set.of(
|
||||
|
||||
+290
-3
@@ -6,7 +6,10 @@ import io.github.hectorvent.floci.core.common.XmlBuilder;
|
||||
import io.github.hectorvent.floci.services.cloudformation.model.ChangeSet;
|
||||
import io.github.hectorvent.floci.services.cloudformation.model.Stack;
|
||||
import io.github.hectorvent.floci.services.cloudformation.model.StackEvent;
|
||||
import io.github.hectorvent.floci.services.cloudformation.model.StackInstance;
|
||||
import io.github.hectorvent.floci.services.cloudformation.model.StackResource;
|
||||
import io.github.hectorvent.floci.services.cloudformation.model.StackSet;
|
||||
import io.github.hectorvent.floci.services.cloudformation.model.StackSetOperation;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.core.MultivaluedMap;
|
||||
@@ -32,10 +35,12 @@ public class CloudFormationQueryHandler {
|
||||
private static final String CF_NS = "http://cloudformation.amazonaws.com/doc/2010-05-15/";
|
||||
|
||||
private final CloudFormationService cfnService;
|
||||
private final StackSetService stackSetService;
|
||||
|
||||
@Inject
|
||||
public CloudFormationQueryHandler(CloudFormationService cfnService) {
|
||||
public CloudFormationQueryHandler(CloudFormationService cfnService, StackSetService stackSetService) {
|
||||
this.cfnService = cfnService;
|
||||
this.stackSetService = stackSetService;
|
||||
}
|
||||
|
||||
public Response handle(String action, MultivaluedMap<String, String> params, String region) {
|
||||
@@ -59,8 +64,17 @@ public class CloudFormationQueryHandler {
|
||||
case "SetStackPolicy" -> Response.ok(emptyResult("SetStackPolicyResponse")).build();
|
||||
case "GetStackPolicy" -> Response.ok(emptyResult("GetStackPolicyResponse")).build();
|
||||
case "DescribeStackResource" -> describeStackResource(params, region);
|
||||
case "ListStackSets", "DescribeStackSet", "CreateStackSet" ->
|
||||
Response.ok(emptyResult(action + "Response")).build();
|
||||
case "CreateStackSet" -> createStackSet(params);
|
||||
case "DescribeStackSet" -> describeStackSet(params);
|
||||
case "ListStackSets" -> listStackSets();
|
||||
case "UpdateStackSet" -> updateStackSet(params);
|
||||
case "DeleteStackSet" -> deleteStackSet(params);
|
||||
case "CreateStackInstances" -> createStackInstances(params, region);
|
||||
case "ListStackInstances" -> listStackInstances(params);
|
||||
case "DescribeStackInstance" -> describeStackInstance(params);
|
||||
case "DeleteStackInstances" -> deleteStackInstances(params);
|
||||
case "ListStackSetOperations" -> listStackSetOperations(params);
|
||||
case "DescribeStackSetOperation" -> describeStackSetOperation(params);
|
||||
default -> xmlError("UnknownAction", "Action " + action + " is not supported.", 400);
|
||||
};
|
||||
}
|
||||
@@ -565,6 +579,279 @@ public class CloudFormationQueryHandler {
|
||||
.build();
|
||||
}
|
||||
|
||||
// ── StackSets ─────────────────────────────────────────────────────────────
|
||||
|
||||
private Response createStackSet(MultivaluedMap<String, String> params) {
|
||||
try {
|
||||
StackSet ss = stackSetService.createStackSet(
|
||||
params.getFirst("StackSetName"),
|
||||
cfnService.resolveTemplateBody(params.getFirst("TemplateBody"), params.getFirst("TemplateURL")),
|
||||
extractParameters(params),
|
||||
extractList(params, "Capabilities.member."),
|
||||
extractTags(params),
|
||||
params.getFirst("Description"));
|
||||
String xml = new XmlBuilder()
|
||||
.start("CreateStackSetResponse", CF_NS)
|
||||
.start("CreateStackSetResult")
|
||||
.elem("StackSetId", ss.getStackSetId())
|
||||
.end("CreateStackSetResult")
|
||||
.raw(AwsQueryResponse.responseMetadata())
|
||||
.end("CreateStackSetResponse")
|
||||
.build();
|
||||
return Response.ok(xml).type("text/xml").build();
|
||||
} catch (AwsException e) {
|
||||
return xmlError(e.getErrorCode(), e.getMessage(), e.getHttpStatus());
|
||||
}
|
||||
}
|
||||
|
||||
private Response describeStackSet(MultivaluedMap<String, String> params) {
|
||||
try {
|
||||
StackSet ss = stackSetService.describeStackSet(params.getFirst("StackSetName"));
|
||||
XmlBuilder xml = new XmlBuilder()
|
||||
.start("DescribeStackSetResponse", CF_NS)
|
||||
.start("DescribeStackSetResult")
|
||||
.start("StackSet")
|
||||
.elem("StackSetName", ss.getStackSetName())
|
||||
.elem("StackSetId", ss.getStackSetId())
|
||||
.elem("Status", ss.getStatus())
|
||||
.elem("Description", ss.getDescription())
|
||||
.elem("TemplateBody", ss.getTemplateBody())
|
||||
.elem("PermissionModel", ss.getPermissionModel());
|
||||
appendCapabilities(xml, ss.getCapabilities());
|
||||
appendParameters(xml, ss.getParameters());
|
||||
xml.end("StackSet").end("DescribeStackSetResult")
|
||||
.raw(AwsQueryResponse.responseMetadata())
|
||||
.end("DescribeStackSetResponse");
|
||||
return Response.ok(xml.build()).type("text/xml").build();
|
||||
} catch (AwsException e) {
|
||||
return xmlError(e.getErrorCode(), e.getMessage(), e.getHttpStatus());
|
||||
}
|
||||
}
|
||||
|
||||
private Response listStackSets() {
|
||||
XmlBuilder xml = new XmlBuilder()
|
||||
.start("ListStackSetsResponse", CF_NS)
|
||||
.start("ListStackSetsResult")
|
||||
.start("Summaries");
|
||||
for (StackSet ss : stackSetService.listStackSets()) {
|
||||
xml.start("member")
|
||||
.elem("StackSetName", ss.getStackSetName())
|
||||
.elem("StackSetId", ss.getStackSetId())
|
||||
.elem("Status", ss.getStatus())
|
||||
.elem("Description", ss.getDescription())
|
||||
.end("member");
|
||||
}
|
||||
xml.end("Summaries").end("ListStackSetsResult")
|
||||
.raw(AwsQueryResponse.responseMetadata())
|
||||
.end("ListStackSetsResponse");
|
||||
return Response.ok(xml.build()).type("text/xml").build();
|
||||
}
|
||||
|
||||
private Response updateStackSet(MultivaluedMap<String, String> params) {
|
||||
try {
|
||||
StackSetOperation op = stackSetService.updateStackSet(
|
||||
params.getFirst("StackSetName"),
|
||||
cfnService.resolveTemplateBody(params.getFirst("TemplateBody"), params.getFirst("TemplateURL")),
|
||||
extractParameters(params),
|
||||
extractList(params, "Capabilities.member."),
|
||||
extractTags(params),
|
||||
params.getFirst("Description"));
|
||||
return operationResponse("UpdateStackSet", op.getOperationId());
|
||||
} catch (AwsException e) {
|
||||
return xmlError(e.getErrorCode(), e.getMessage(), e.getHttpStatus());
|
||||
}
|
||||
}
|
||||
|
||||
private Response deleteStackSet(MultivaluedMap<String, String> params) {
|
||||
try {
|
||||
stackSetService.deleteStackSet(params.getFirst("StackSetName"));
|
||||
return Response.ok(emptyResult("DeleteStackSetResponse")).type("text/xml").build();
|
||||
} catch (AwsException e) {
|
||||
return xmlError(e.getErrorCode(), e.getMessage(), e.getHttpStatus());
|
||||
}
|
||||
}
|
||||
|
||||
private Response createStackInstances(MultivaluedMap<String, String> params, String region) {
|
||||
try {
|
||||
StackSetOperation op = stackSetService.createStackInstances(
|
||||
params.getFirst("StackSetName"),
|
||||
extractList(params, "Accounts.member."),
|
||||
resolveRegions(params, region));
|
||||
return operationResponse("CreateStackInstances", op.getOperationId());
|
||||
} catch (AwsException e) {
|
||||
return xmlError(e.getErrorCode(), e.getMessage(), e.getHttpStatus());
|
||||
}
|
||||
}
|
||||
|
||||
private Response listStackInstances(MultivaluedMap<String, String> params) {
|
||||
try {
|
||||
List<StackInstance> list = stackSetService.listStackInstances(
|
||||
params.getFirst("StackSetName"),
|
||||
params.getFirst("StackInstanceAccount"),
|
||||
params.getFirst("StackInstanceRegion"));
|
||||
XmlBuilder xml = new XmlBuilder()
|
||||
.start("ListStackInstancesResponse", CF_NS)
|
||||
.start("ListStackInstancesResult")
|
||||
.start("Summaries");
|
||||
for (StackInstance inst : list) {
|
||||
xml.start("member")
|
||||
.elem("StackSetId", inst.getStackSetId())
|
||||
.elem("Account", inst.getAccount())
|
||||
.elem("Region", inst.getRegion())
|
||||
.elem("StackId", inst.getStackId())
|
||||
.elem("Status", inst.getStatus())
|
||||
.start("StackInstanceStatus")
|
||||
.elem("DetailedStatus", inst.getDetailedStatus())
|
||||
.end("StackInstanceStatus")
|
||||
.elem("StatusReason", inst.getStatusReason())
|
||||
.end("member");
|
||||
}
|
||||
xml.end("Summaries").end("ListStackInstancesResult")
|
||||
.raw(AwsQueryResponse.responseMetadata())
|
||||
.end("ListStackInstancesResponse");
|
||||
return Response.ok(xml.build()).type("text/xml").build();
|
||||
} catch (AwsException e) {
|
||||
return xmlError(e.getErrorCode(), e.getMessage(), e.getHttpStatus());
|
||||
}
|
||||
}
|
||||
|
||||
private Response describeStackInstance(MultivaluedMap<String, String> params) {
|
||||
try {
|
||||
StackInstance inst = stackSetService.describeStackInstance(
|
||||
params.getFirst("StackSetName"),
|
||||
params.getFirst("StackInstanceAccount"),
|
||||
params.getFirst("StackInstanceRegion"));
|
||||
String xml = new XmlBuilder()
|
||||
.start("DescribeStackInstanceResponse", CF_NS)
|
||||
.start("DescribeStackInstanceResult")
|
||||
.start("StackInstance")
|
||||
.elem("StackSetId", inst.getStackSetId())
|
||||
.elem("Account", inst.getAccount())
|
||||
.elem("Region", inst.getRegion())
|
||||
.elem("StackId", inst.getStackId())
|
||||
.elem("Status", inst.getStatus())
|
||||
.start("StackInstanceStatus")
|
||||
.elem("DetailedStatus", inst.getDetailedStatus())
|
||||
.end("StackInstanceStatus")
|
||||
.elem("StatusReason", inst.getStatusReason())
|
||||
.end("StackInstance")
|
||||
.end("DescribeStackInstanceResult")
|
||||
.raw(AwsQueryResponse.responseMetadata())
|
||||
.end("DescribeStackInstanceResponse")
|
||||
.build();
|
||||
return Response.ok(xml).type("text/xml").build();
|
||||
} catch (AwsException e) {
|
||||
return xmlError(e.getErrorCode(), e.getMessage(), e.getHttpStatus());
|
||||
}
|
||||
}
|
||||
|
||||
private Response deleteStackInstances(MultivaluedMap<String, String> params) {
|
||||
try {
|
||||
StackSetOperation op = stackSetService.deleteStackInstances(
|
||||
params.getFirst("StackSetName"),
|
||||
extractList(params, "Accounts.member."),
|
||||
extractList(params, "Regions.member."),
|
||||
Boolean.parseBoolean(params.getFirst("RetainStacks")));
|
||||
return operationResponse("DeleteStackInstances", op.getOperationId());
|
||||
} catch (AwsException e) {
|
||||
return xmlError(e.getErrorCode(), e.getMessage(), e.getHttpStatus());
|
||||
}
|
||||
}
|
||||
|
||||
private Response listStackSetOperations(MultivaluedMap<String, String> params) {
|
||||
try {
|
||||
List<StackSetOperation> ops = stackSetService.listStackSetOperations(params.getFirst("StackSetName"));
|
||||
XmlBuilder xml = new XmlBuilder()
|
||||
.start("ListStackSetOperationsResponse", CF_NS)
|
||||
.start("ListStackSetOperationsResult")
|
||||
.start("Summaries");
|
||||
for (StackSetOperation op : ops) {
|
||||
xml.start("member")
|
||||
.elem("OperationId", op.getOperationId())
|
||||
.elem("Action", op.getAction())
|
||||
.elem("Status", op.getStatus())
|
||||
.elem("CreationTimestamp", ISO.format(op.getCreationTimestamp()));
|
||||
if (op.getEndTimestamp() != null) {
|
||||
xml.elem("EndTimestamp", ISO.format(op.getEndTimestamp()));
|
||||
}
|
||||
xml.end("member");
|
||||
}
|
||||
xml.end("Summaries").end("ListStackSetOperationsResult")
|
||||
.raw(AwsQueryResponse.responseMetadata())
|
||||
.end("ListStackSetOperationsResponse");
|
||||
return Response.ok(xml.build()).type("text/xml").build();
|
||||
} catch (AwsException e) {
|
||||
return xmlError(e.getErrorCode(), e.getMessage(), e.getHttpStatus());
|
||||
}
|
||||
}
|
||||
|
||||
private Response describeStackSetOperation(MultivaluedMap<String, String> params) {
|
||||
try {
|
||||
StackSetOperation op = stackSetService.describeStackSetOperation(
|
||||
params.getFirst("StackSetName"), params.getFirst("OperationId"));
|
||||
XmlBuilder xml = new XmlBuilder()
|
||||
.start("DescribeStackSetOperationResponse", CF_NS)
|
||||
.start("DescribeStackSetOperationResult")
|
||||
.start("StackSetOperation")
|
||||
.elem("OperationId", op.getOperationId())
|
||||
.elem("Action", op.getAction())
|
||||
.elem("Status", op.getStatus())
|
||||
.elem("CreationTimestamp", ISO.format(op.getCreationTimestamp()));
|
||||
if (op.getEndTimestamp() != null) {
|
||||
xml.elem("EndTimestamp", ISO.format(op.getEndTimestamp()));
|
||||
}
|
||||
xml.end("StackSetOperation").end("DescribeStackSetOperationResult")
|
||||
.raw(AwsQueryResponse.responseMetadata())
|
||||
.end("DescribeStackSetOperationResponse");
|
||||
return Response.ok(xml.build()).type("text/xml").build();
|
||||
} catch (AwsException e) {
|
||||
return xmlError(e.getErrorCode(), e.getMessage(), e.getHttpStatus());
|
||||
}
|
||||
}
|
||||
|
||||
private Response operationResponse(String action, String operationId) {
|
||||
String xml = new XmlBuilder()
|
||||
.start(action + "Response", CF_NS)
|
||||
.start(action + "Result")
|
||||
.elem("OperationId", operationId)
|
||||
.end(action + "Result")
|
||||
.raw(AwsQueryResponse.responseMetadata())
|
||||
.end(action + "Response")
|
||||
.build();
|
||||
return Response.ok(xml).type("text/xml").build();
|
||||
}
|
||||
|
||||
/** Falls back to the request region when no explicit Regions are supplied. */
|
||||
private List<String> resolveRegions(MultivaluedMap<String, String> params, String region) {
|
||||
List<String> regions = extractList(params, "Regions.member.");
|
||||
return regions.isEmpty() ? List.of(region) : regions;
|
||||
}
|
||||
|
||||
private void appendCapabilities(XmlBuilder xml, List<String> capabilities) {
|
||||
if (capabilities == null || capabilities.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
xml.start("Capabilities");
|
||||
for (String c : capabilities) {
|
||||
xml.elem("member", c);
|
||||
}
|
||||
xml.end("Capabilities");
|
||||
}
|
||||
|
||||
private void appendParameters(XmlBuilder xml, Map<String, String> parameters) {
|
||||
if (parameters == null || parameters.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
xml.start("Parameters");
|
||||
for (Map.Entry<String, String> e : parameters.entrySet()) {
|
||||
xml.start("member")
|
||||
.elem("ParameterKey", e.getKey())
|
||||
.elem("ParameterValue", e.getValue())
|
||||
.end("member");
|
||||
}
|
||||
xml.end("Parameters");
|
||||
}
|
||||
|
||||
private void awaitExecution(Future<?> future) {
|
||||
try {
|
||||
future.get();
|
||||
|
||||
+75
-4
@@ -4,7 +4,10 @@ import io.github.hectorvent.floci.config.EmulatorConfig;
|
||||
import io.github.hectorvent.floci.core.common.AwsArnUtils;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import io.github.hectorvent.floci.core.common.RequestContext;
|
||||
import io.github.hectorvent.floci.core.common.dns.EmbeddedDnsServer;
|
||||
import io.quarkus.arc.Arc;
|
||||
import io.quarkus.arc.ManagedContext;
|
||||
import io.github.hectorvent.floci.core.storage.AccountAwareStorageBackend;
|
||||
import io.github.hectorvent.floci.core.storage.StorageBackend;
|
||||
import io.github.hectorvent.floci.core.storage.StorageFactory;
|
||||
@@ -27,6 +30,7 @@ import java.time.Instant;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
@@ -186,6 +190,18 @@ public class CloudFormationService {
|
||||
// ── ExecuteChangeSet ──────────────────────────────────────────────────────
|
||||
|
||||
public Future<?> executeChangeSet(String stackName, String changeSetName, String region) {
|
||||
return executeChangeSet(stackName, changeSetName, region, regionResolver.getAccountId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a change set, provisioning its resources into {@code accountId}'s namespace.
|
||||
*
|
||||
* <p>Provisioning runs on a background executor thread that has no inherited request scope, so
|
||||
* the downstream service calls would otherwise fall back to the default account. The resources
|
||||
* are materialized under a synthetic request scope bound to {@code accountId} so a single-stack
|
||||
* deployment lands in the caller's account, and a StackSet instance lands in its target account.
|
||||
*/
|
||||
public Future<?> executeChangeSet(String stackName, String changeSetName, String region, String accountId) {
|
||||
Stack stack = getStackOrThrow(stackName, region);
|
||||
ChangeSet cs = stack.getChangeSets().get(resolveChangeSetName(changeSetName));
|
||||
if (cs == null) {
|
||||
@@ -205,8 +221,38 @@ public class CloudFormationService {
|
||||
String templateBody = cs.getTemplateBody();
|
||||
Map<String, String> params = cs.getParameters() != null ? cs.getParameters() : Map.of();
|
||||
|
||||
String accountId = regionResolver.getAccountId();
|
||||
return executor.submit(() -> executeTemplate(stack, templateBody, params, isCreate, region, accountId));
|
||||
return executor.submit(() -> runUnderAccount(accountId,
|
||||
() -> executeTemplate(stack, templateBody, params, isCreate, region, accountId)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs {@code body} under a synthetic CDI request scope whose account is {@code accountId}, so
|
||||
* that account-aware storage in the downstream services namespaces provisioned resources under
|
||||
* the intended account. Mirrors the pattern used by other background workers.
|
||||
*/
|
||||
private void runUnderAccount(String accountId, Runnable body) {
|
||||
ManagedContext requestContext = Arc.container().requestContext();
|
||||
boolean alreadyActive = requestContext.isActive();
|
||||
if (!alreadyActive) {
|
||||
requestContext.activate();
|
||||
}
|
||||
// Background workers normally have no active scope, so a fresh one is activated and
|
||||
// terminated below. But if we ran inside an already-active scope, restore its previous
|
||||
// account afterwards so we never leave the overridden account ID behind on a reused thread.
|
||||
RequestContext ctx = Arc.container().instance(RequestContext.class).get();
|
||||
String previousAccountId = alreadyActive ? ctx.getAccountId() : null;
|
||||
try {
|
||||
if (accountId != null) {
|
||||
ctx.setAccountId(accountId);
|
||||
}
|
||||
body.run();
|
||||
} finally {
|
||||
if (!alreadyActive) {
|
||||
requestContext.terminate();
|
||||
} else {
|
||||
ctx.setAccountId(previousAccountId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ── DeleteChangeSet ───────────────────────────────────────────────────────
|
||||
@@ -226,16 +272,29 @@ public class CloudFormationService {
|
||||
// ── DeleteStack ───────────────────────────────────────────────────────────
|
||||
|
||||
public void deleteStack(String stackName, String region) {
|
||||
deleteStack(stackName, region, regionResolver.getAccountId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a stack, removing its resources from {@code accountId}'s namespace. The account must
|
||||
* match the one the resources were provisioned into (the caller's account for a single-stack
|
||||
* deployment, or the target account for a StackSet instance).
|
||||
*
|
||||
* @return a future that completes when the resources have been removed; already-gone stacks
|
||||
* complete immediately. Callers that need synchronous deletion (e.g. StackSet instance
|
||||
* removal) can await it.
|
||||
*/
|
||||
public Future<?> deleteStack(String stackName, String region, String accountId) {
|
||||
purgeExpiredDeletedStacks();
|
||||
Stack stack = resolveStack(stackName, region);
|
||||
if (stack == null) {
|
||||
return; // Already gone — no-op
|
||||
return CompletableFuture.completedFuture(null); // Already gone — no-op
|
||||
}
|
||||
stack.setStatus("DELETE_IN_PROGRESS");
|
||||
addEvent(stack, stack.getStackName(), stack.getStackId(),
|
||||
"AWS::CloudFormation::Stack", "DELETE_IN_PROGRESS", null);
|
||||
|
||||
executor.submit(() -> deleteStackResources(stack, region));
|
||||
return executor.submit(() -> runUnderAccount(accountId, () -> deleteStackResources(stack, region)));
|
||||
}
|
||||
|
||||
// ── GetTemplate ───────────────────────────────────────────────────────────
|
||||
@@ -706,6 +765,18 @@ public class CloudFormationService {
|
||||
return "{}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves a template body from an inline body or a TemplateURL (fetched from S3), for callers
|
||||
* outside this service such as the StackSets handler. Returns {@code null} when neither is given.
|
||||
*/
|
||||
public String resolveTemplateBody(String templateBody, String templateUrl) {
|
||||
if ((templateBody == null || templateBody.isBlank())
|
||||
&& (templateUrl == null || templateUrl.isBlank())) {
|
||||
return null;
|
||||
}
|
||||
return resolveTemplate(templateBody, templateUrl);
|
||||
}
|
||||
|
||||
private String fetchTemplateFromS3(String url) {
|
||||
// Parse S3 URL — three forms:
|
||||
// Virtual-hosted AWS: https://bucket.s3[.region].amazonaws.com/key
|
||||
|
||||
+334
@@ -0,0 +1,334 @@
|
||||
package io.github.hectorvent.floci.services.cloudformation;
|
||||
|
||||
import io.github.hectorvent.floci.core.common.AwsArnUtils;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.storage.StorageBackend;
|
||||
import io.github.hectorvent.floci.core.storage.StorageFactory;
|
||||
import io.github.hectorvent.floci.services.cloudformation.model.Stack;
|
||||
import io.github.hectorvent.floci.services.cloudformation.model.StackInstance;
|
||||
import io.github.hectorvent.floci.services.cloudformation.model.StackSet;
|
||||
import io.github.hectorvent.floci.services.cloudformation.model.StackSetOperation;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
/**
|
||||
* CloudFormation StackSets — manages stack sets and provisions their instances across target
|
||||
* accounts and regions.
|
||||
*
|
||||
* <p>A StackSet holds a template and configuration; {@code CreateStackInstances} drives the existing
|
||||
* single-stack engine ({@link CloudFormationService}) once per target {@code (account, region)},
|
||||
* provisioning the resources into each target account's namespace. The StackSet, instance and
|
||||
* operation records themselves live in the administration (caller) account's namespace.
|
||||
*/
|
||||
@ApplicationScoped
|
||||
public class StackSetService {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(StackSetService.class);
|
||||
private static final String INSTANCE_CHANGE_SET = "stackset-instance";
|
||||
private static final String UPDATE_CHANGE_SET = "stackset-update";
|
||||
|
||||
private final CloudFormationService cfnService;
|
||||
private final StorageBackend<String, StackSet> stackSets;
|
||||
private final StorageBackend<String, StackInstance> instances;
|
||||
private final StorageBackend<String, StackSetOperation> operations;
|
||||
|
||||
@Inject
|
||||
public StackSetService(CloudFormationService cfnService, StorageFactory storageFactory) {
|
||||
this.cfnService = cfnService;
|
||||
this.stackSets = storageFactory.create("cloudformation", "cloudformation-stacksets.json",
|
||||
new TypeReference<Map<String, StackSet>>() {});
|
||||
this.instances = storageFactory.create("cloudformation", "cloudformation-stackset-instances.json",
|
||||
new TypeReference<Map<String, StackInstance>>() {});
|
||||
this.operations = storageFactory.create("cloudformation", "cloudformation-stackset-operations.json",
|
||||
new TypeReference<Map<String, StackSetOperation>>() {});
|
||||
}
|
||||
|
||||
// ── StackSet lifecycle ─────────────────────────────────────────────────────
|
||||
|
||||
public StackSet createStackSet(String name, String templateBody, Map<String, String> parameters,
|
||||
List<String> capabilities, Map<String, String> tags, String description) {
|
||||
if (name == null || name.isBlank()) {
|
||||
throw new AwsException("ValidationError", "StackSetName must not be empty", 400);
|
||||
}
|
||||
if (stackSets.get(name).isPresent()) {
|
||||
throw new AwsException("NameAlreadyExistsException",
|
||||
"StackSet already exists: " + name, 409);
|
||||
}
|
||||
// AWS rejects CreateStackSet with no template; the handler resolves TemplateBody/TemplateURL
|
||||
// to null when neither is supplied. Without this guard a later CreateStackInstances would
|
||||
// deploy empty ("{}") stacks into every target account.
|
||||
if (templateBody == null || templateBody.isBlank()) {
|
||||
throw new AwsException("ValidationError",
|
||||
"Either TemplateBody or TemplateURL must be specified", 400);
|
||||
}
|
||||
StackSet ss = new StackSet();
|
||||
ss.setStackSetName(name);
|
||||
ss.setStackSetId(name + ":" + UUID.randomUUID());
|
||||
ss.setTemplateBody(templateBody);
|
||||
ss.setDescription(description);
|
||||
if (parameters != null) {
|
||||
ss.setParameters(new LinkedHashMap<>(parameters));
|
||||
}
|
||||
if (capabilities != null) {
|
||||
ss.getCapabilities().addAll(capabilities);
|
||||
}
|
||||
if (tags != null) {
|
||||
ss.getTags().putAll(tags);
|
||||
}
|
||||
stackSets.put(name, ss);
|
||||
LOG.infov("Created StackSet: {0}", name);
|
||||
return ss;
|
||||
}
|
||||
|
||||
public StackSet describeStackSet(String name) {
|
||||
return getStackSetOrThrow(name);
|
||||
}
|
||||
|
||||
public List<StackSet> listStackSets() {
|
||||
return stackSets.scan(k -> true);
|
||||
}
|
||||
|
||||
public StackSetOperation updateStackSet(String name, String templateBody, Map<String, String> parameters,
|
||||
List<String> capabilities, Map<String, String> tags,
|
||||
String description) {
|
||||
StackSet ss = getStackSetOrThrow(name);
|
||||
if (templateBody != null && !templateBody.isBlank()) {
|
||||
ss.setTemplateBody(templateBody);
|
||||
}
|
||||
if (parameters != null && !parameters.isEmpty()) {
|
||||
ss.setParameters(new LinkedHashMap<>(parameters));
|
||||
}
|
||||
if (capabilities != null && !capabilities.isEmpty()) {
|
||||
ss.getCapabilities().clear();
|
||||
ss.getCapabilities().addAll(capabilities);
|
||||
}
|
||||
if (tags != null && !tags.isEmpty()) {
|
||||
ss.getTags().clear();
|
||||
ss.getTags().putAll(tags);
|
||||
}
|
||||
if (description != null) {
|
||||
ss.setDescription(description);
|
||||
}
|
||||
stackSets.put(name, ss);
|
||||
|
||||
// Re-apply the updated definition to every existing instance, refreshing each record.
|
||||
List<StackInstance> deployed = new ArrayList<>();
|
||||
for (StackInstance inst : listStackInstances(name, null, null)) {
|
||||
StackInstance updated = deployInstance(ss, inst.getAccount(), inst.getRegion(), UPDATE_CHANGE_SET, "UPDATE");
|
||||
instances.put(instanceKey(name, updated.getAccount(), updated.getRegion()), updated);
|
||||
deployed.add(updated);
|
||||
}
|
||||
return recordOperation(name, "UPDATE", deriveOperationStatus(deployed));
|
||||
}
|
||||
|
||||
public void deleteStackSet(String name) {
|
||||
getStackSetOrThrow(name);
|
||||
if (!listStackInstances(name, null, null).isEmpty()) {
|
||||
throw new AwsException("StackSetNotEmptyException",
|
||||
"StackSet is not empty. Delete all stack instances first.", 409);
|
||||
}
|
||||
stackSets.delete(name);
|
||||
LOG.infov("Deleted StackSet: {0}", name);
|
||||
}
|
||||
|
||||
// ── Instances ──────────────────────────────────────────────────────────────
|
||||
|
||||
public StackSetOperation createStackInstances(String name, List<String> accounts, List<String> regions) {
|
||||
StackSet ss = getStackSetOrThrow(name);
|
||||
if (accounts == null || accounts.isEmpty() || regions == null || regions.isEmpty()) {
|
||||
throw new AwsException("ValidationError",
|
||||
"Accounts and Regions must each contain at least one value", 400);
|
||||
}
|
||||
List<StackInstance> deployed = new ArrayList<>();
|
||||
for (String account : accounts) {
|
||||
for (String region : regions) {
|
||||
StackInstance inst = deployInstance(ss, account, region, INSTANCE_CHANGE_SET, "CREATE");
|
||||
instances.put(instanceKey(name, account, region), inst);
|
||||
deployed.add(inst);
|
||||
}
|
||||
}
|
||||
return recordOperation(name, "CREATE", deriveOperationStatus(deployed));
|
||||
}
|
||||
|
||||
public List<StackInstance> listStackInstances(String name, String accountFilter, String regionFilter) {
|
||||
getStackSetOrThrow(name);
|
||||
String prefix = name + ":";
|
||||
return instances.scan(k -> k.startsWith(prefix)).stream()
|
||||
.filter(i -> accountFilter == null || accountFilter.equals(i.getAccount()))
|
||||
.filter(i -> regionFilter == null || regionFilter.equals(i.getRegion()))
|
||||
.toList();
|
||||
}
|
||||
|
||||
public StackInstance describeStackInstance(String name, String account, String region) {
|
||||
getStackSetOrThrow(name);
|
||||
if (account == null || region == null) {
|
||||
throw new AwsException("ValidationError",
|
||||
"StackInstanceAccount and StackInstanceRegion are required", 400);
|
||||
}
|
||||
return instances.get(instanceKey(name, account, region))
|
||||
.orElseThrow(() -> new AwsException("StackInstanceNotFoundException",
|
||||
"Stack instance for [" + account + "/" + region + "] not found in stack set " + name, 404));
|
||||
}
|
||||
|
||||
public StackSetOperation deleteStackInstances(String name, List<String> accounts, List<String> regions,
|
||||
boolean retainStacks) {
|
||||
getStackSetOrThrow(name);
|
||||
if (accounts == null || accounts.isEmpty() || regions == null || regions.isEmpty()) {
|
||||
throw new AwsException("ValidationError",
|
||||
"Accounts and Regions must each contain at least one value", 400);
|
||||
}
|
||||
List<StackInstance> results = new ArrayList<>();
|
||||
for (String account : accounts) {
|
||||
for (String region : regions) {
|
||||
String key = instanceKey(name, account, region);
|
||||
StackInstance inst = instances.get(key).orElse(null);
|
||||
if (inst == null) {
|
||||
continue;
|
||||
}
|
||||
// RetainStacks=true detaches the instance from the StackSet but leaves the
|
||||
// underlying CloudFormation stack and its resources in the target account.
|
||||
if (!retainStacks && !await(cfnService.deleteStack(inst.getStackName(), region, account))) {
|
||||
// The underlying stack delete failed. Match AWS: retain the instance record
|
||||
// (now INOPERABLE) and report the operation as FAILED, rather than silently
|
||||
// dropping the instance and claiming success.
|
||||
inst.setStatus("INOPERABLE");
|
||||
inst.setDetailedStatus("FAILED");
|
||||
inst.setStatusReason("Stack instance deletion failed");
|
||||
instances.put(key, inst);
|
||||
results.add(inst);
|
||||
continue;
|
||||
}
|
||||
inst.setDetailedStatus("SUCCEEDED");
|
||||
instances.delete(key);
|
||||
results.add(inst);
|
||||
}
|
||||
}
|
||||
return recordOperation(name, "DELETE", deriveOperationStatus(results));
|
||||
}
|
||||
|
||||
public List<StackSetOperation> listStackSetOperations(String name) {
|
||||
getStackSetOrThrow(name);
|
||||
String prefix = name + ":";
|
||||
return operations.scan(k -> k.startsWith(prefix)).stream()
|
||||
.sorted((a, b) -> b.getCreationTimestamp().compareTo(a.getCreationTimestamp()))
|
||||
.toList();
|
||||
}
|
||||
|
||||
public StackSetOperation describeStackSetOperation(String name, String operationId) {
|
||||
getStackSetOrThrow(name);
|
||||
if (operationId == null || operationId.isBlank()) {
|
||||
throw new AwsException("ValidationError", "OperationId is required", 400);
|
||||
}
|
||||
return operations.get(name + ":" + operationId)
|
||||
.orElseThrow(() -> new AwsException("OperationNotFoundException",
|
||||
"Operation " + operationId + " not found for stack set " + name, 404));
|
||||
}
|
||||
|
||||
// ── Internal helpers ────────────────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* Drives the single-stack engine to materialize one instance's resources into the target
|
||||
* account's namespace, then returns a {@link StackInstance} describing it.
|
||||
*/
|
||||
private StackInstance deployInstance(StackSet ss, String account, String region,
|
||||
String changeSetName, String changeSetType) {
|
||||
String stackName = instanceStackName(ss.getStackSetName(), account);
|
||||
cfnService.createChangeSet(stackName, changeSetName, changeSetType, ss.getTemplateBody(), null,
|
||||
ss.getParameters(), ss.getCapabilities(), ss.getTags(), region);
|
||||
await(cfnService.executeChangeSet(stackName, changeSetName, region, account));
|
||||
|
||||
StackInstance inst = new StackInstance();
|
||||
inst.setStackSetId(ss.getStackSetId());
|
||||
inst.setStackSetName(ss.getStackSetName());
|
||||
inst.setAccount(account);
|
||||
inst.setRegion(region);
|
||||
inst.setStackName(stackName);
|
||||
inst.setStackId(resolveStackId(stackName, region, account));
|
||||
List<Stack> stacks = cfnService.describeStacks(stackName, region);
|
||||
String stackStatus = stacks.isEmpty() ? null : stacks.get(0).getStatus();
|
||||
// Only a clean create/update is a success. A failed resource rolls the stack back, so its
|
||||
// terminal status is ROLLBACK_COMPLETE (not *_FAILED) — treat anything that is not COMPLETE
|
||||
// as a failed instance so the operation status reflects it.
|
||||
if (!"CREATE_COMPLETE".equals(stackStatus) && !"UPDATE_COMPLETE".equals(stackStatus)) {
|
||||
inst.setStatus("INOPERABLE");
|
||||
inst.setDetailedStatus("FAILED");
|
||||
inst.setStatusReason(stacks.isEmpty() ? null : stacks.get(0).getStatusReason());
|
||||
} else {
|
||||
inst.setDetailedStatus("SUCCEEDED");
|
||||
}
|
||||
return inst;
|
||||
}
|
||||
|
||||
private String resolveStackId(String stackName, String region, String account) {
|
||||
List<Stack> stacks = cfnService.describeStacks(stackName, region);
|
||||
if (!stacks.isEmpty() && stacks.get(0).getStackId() != null) {
|
||||
return stacks.get(0).getStackId();
|
||||
}
|
||||
return AwsArnUtils.Arn.of("cloudformation", region, account, "stack/" + stackName).toString();
|
||||
}
|
||||
|
||||
private StackSetOperation recordOperation(String stackSetName, String action, String status) {
|
||||
StackSetOperation op = new StackSetOperation(UUID.randomUUID().toString(), stackSetName, action);
|
||||
op.setStatus(status);
|
||||
op.setEndTimestamp(Instant.now());
|
||||
operations.put(stackSetName + ":" + op.getOperationId(), op);
|
||||
return op;
|
||||
}
|
||||
|
||||
/**
|
||||
* An operation is FAILED if any of its instances did not deploy cleanly; otherwise SUCCEEDED.
|
||||
* Without this, a failed (INOPERABLE) instance would still report SUCCEEDED to anything polling
|
||||
* {@code DescribeStackSetOperation}.
|
||||
*/
|
||||
private static String deriveOperationStatus(List<StackInstance> deployedInstances) {
|
||||
boolean anyFailed = deployedInstances.stream()
|
||||
.anyMatch(i -> "FAILED".equals(i.getDetailedStatus()));
|
||||
return anyFailed ? "FAILED" : "SUCCEEDED";
|
||||
}
|
||||
|
||||
private StackSet getStackSetOrThrow(String name) {
|
||||
return stackSets.get(name)
|
||||
.orElseThrow(() -> new AwsException("StackSetNotFoundException",
|
||||
"StackSet [" + name + "] not found", 404));
|
||||
}
|
||||
|
||||
private static String instanceStackName(String stackSetName, String account) {
|
||||
return "StackSet-" + stackSetName + "-" + account;
|
||||
}
|
||||
|
||||
private static String instanceKey(String stackSetName, String account, String region) {
|
||||
return stackSetName + ":" + account + ":" + region;
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits for an instance operation to complete. Returns {@code true} if it finished cleanly and
|
||||
* {@code false} if it failed (the failure is logged). Callers that must react to a failure —
|
||||
* {@link #deleteStackInstances} cannot drop an instance whose underlying stack delete failed —
|
||||
* inspect the result; fire-and-forget callers can ignore it.
|
||||
*/
|
||||
private boolean await(Future<?> future) {
|
||||
try {
|
||||
future.get();
|
||||
return true;
|
||||
} catch (InterruptedException e) {
|
||||
// Restore the interrupt flag so a shutdown signal (e.g. Quarkus interrupting the backing
|
||||
// ExecutorService) propagates instead of being swallowed and letting the thread run on.
|
||||
Thread.currentThread().interrupt();
|
||||
LOG.warnv("StackSet instance execution interrupted: {0}", e.getMessage());
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
LOG.warnv("StackSet instance execution failed: {0}", e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package io.github.hectorvent.floci.services.cloudformation.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class StackInstance {
|
||||
private String stackSetId;
|
||||
private String stackSetName;
|
||||
private String account;
|
||||
private String region;
|
||||
/** Name of the backing single stack that materializes this instance's resources. */
|
||||
private String stackName;
|
||||
private String stackId;
|
||||
/** Drift status (CURRENT, OUTDATED, INOPERABLE). */
|
||||
private String status = "CURRENT";
|
||||
/** Last operation status (SUCCEEDED, FAILED, ...) reported under StackInstanceStatus.DetailedStatus. */
|
||||
private String detailedStatus = "SUCCEEDED";
|
||||
private String statusReason;
|
||||
|
||||
public String getStackSetId() { return stackSetId; }
|
||||
public void setStackSetId(String stackSetId) { this.stackSetId = stackSetId; }
|
||||
public String getStackSetName() { return stackSetName; }
|
||||
public void setStackSetName(String stackSetName) { this.stackSetName = stackSetName; }
|
||||
public String getAccount() { return account; }
|
||||
public void setAccount(String account) { this.account = account; }
|
||||
public String getRegion() { return region; }
|
||||
public void setRegion(String region) { this.region = region; }
|
||||
public String getStackName() { return stackName; }
|
||||
public void setStackName(String stackName) { this.stackName = stackName; }
|
||||
public String getStackId() { return stackId; }
|
||||
public void setStackId(String stackId) { this.stackId = stackId; }
|
||||
public String getStatus() { return status; }
|
||||
public void setStatus(String status) { this.status = status; }
|
||||
public String getDetailedStatus() { return detailedStatus; }
|
||||
public void setDetailedStatus(String detailedStatus) { this.detailedStatus = detailedStatus; }
|
||||
public String getStatusReason() { return statusReason; }
|
||||
public void setStatusReason(String statusReason) { this.statusReason = statusReason; }
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package io.github.hectorvent.floci.services.cloudformation.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class StackSet {
|
||||
private String stackSetId;
|
||||
private String stackSetName;
|
||||
private String description;
|
||||
private String status = "ACTIVE";
|
||||
private String templateBody;
|
||||
private List<String> capabilities = new ArrayList<>();
|
||||
private Map<String, String> parameters = new LinkedHashMap<>();
|
||||
private Map<String, String> tags = new LinkedHashMap<>();
|
||||
/** SELF_MANAGED or SERVICE_MANAGED; Floci only models SELF_MANAGED behavior. */
|
||||
private String permissionModel = "SELF_MANAGED";
|
||||
|
||||
public String getStackSetId() { return stackSetId; }
|
||||
public void setStackSetId(String stackSetId) { this.stackSetId = stackSetId; }
|
||||
public String getStackSetName() { return stackSetName; }
|
||||
public void setStackSetName(String stackSetName) { this.stackSetName = stackSetName; }
|
||||
public String getDescription() { return description; }
|
||||
public void setDescription(String description) { this.description = description; }
|
||||
public String getStatus() { return status; }
|
||||
public void setStatus(String status) { this.status = status; }
|
||||
public String getTemplateBody() { return templateBody; }
|
||||
public void setTemplateBody(String templateBody) { this.templateBody = templateBody; }
|
||||
public List<String> getCapabilities() { return capabilities; }
|
||||
public void setCapabilities(List<String> capabilities) { this.capabilities = capabilities; }
|
||||
public Map<String, String> getParameters() { return parameters; }
|
||||
public void setParameters(Map<String, String> parameters) { this.parameters = parameters; }
|
||||
public Map<String, String> getTags() { return tags; }
|
||||
public void setTags(Map<String, String> tags) { this.tags = tags; }
|
||||
public String getPermissionModel() { return permissionModel; }
|
||||
public void setPermissionModel(String permissionModel) { this.permissionModel = permissionModel; }
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
package io.github.hectorvent.floci.services.cloudformation.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class StackSetOperation {
|
||||
private String operationId;
|
||||
private String stackSetName;
|
||||
/** CREATE, UPDATE or DELETE. */
|
||||
private String action;
|
||||
private String status = "SUCCEEDED";
|
||||
private Instant creationTimestamp = Instant.now();
|
||||
private Instant endTimestamp;
|
||||
|
||||
public StackSetOperation() {}
|
||||
|
||||
public StackSetOperation(String operationId, String stackSetName, String action) {
|
||||
this.operationId = operationId;
|
||||
this.stackSetName = stackSetName;
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public String getOperationId() { return operationId; }
|
||||
public void setOperationId(String operationId) { this.operationId = operationId; }
|
||||
public String getStackSetName() { return stackSetName; }
|
||||
public void setStackSetName(String stackSetName) { this.stackSetName = stackSetName; }
|
||||
public String getAction() { return action; }
|
||||
public void setAction(String action) { this.action = action; }
|
||||
public String getStatus() { return status; }
|
||||
public void setStatus(String status) { this.status = status; }
|
||||
public Instant getCreationTimestamp() { return creationTimestamp; }
|
||||
public void setCreationTimestamp(Instant creationTimestamp) { this.creationTimestamp = creationTimestamp; }
|
||||
public Instant getEndTimestamp() { return endTimestamp; }
|
||||
public void setEndTimestamp(Instant endTimestamp) { this.endTimestamp = endTimestamp; }
|
||||
}
|
||||
Reference in new issue
Block a user