Class AwsDirectDeployer
- All Implemented Interfaces:
AutoCloseable
Backs CloudForgeDeployment's AWS case: the direct-deploy counterpart to
LocalStackDeployer/MiniStackDeployer, without the emulator-specific steps
(Cognito/RDS secret reconciliation, ECS restarts after secret sync), which AWS handles through
CDK's Secrets Manager integration.
Targets AWS by default, but redirects to a local emulator when Manager itself runs
inside one, using the same LOCALSTACK_ENDPOINT/AWS_ENDPOINT_URL detection
as LocalStackDeployer.resolveEndpoint(). Without the
endpoint override, a Manager instance hosted on LocalStack would call the public
CloudFormation endpoint instead of the emulator.
Every stack created or updated is tagged with the cloudforge:managed/
cloudforge:application/cloudforge:runtime convention that
ApplicationFargateStack/ApplicationEc2Stack apply via
Tags.of(this).add(...). The tags are required by Manager's inventory
(StackListingPolicy) and by the aws:RequestTag/aws:ResourceTag
conditions in ManagerOperatorIamSupport.deployStatements. Those conditions evaluate the
stack-level Tags parameter on the API call, not resource-level tags in the template;
this class controls the former.
Test coverage: AwsDirectDeployerTest runs this class against LocalStack via
the injectable-client constructor, which exercises every code path except AWS's own network
and authentication. The change-set create/execute/wait sequence mirrors
LocalStackDeployer's.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAwsDirectDeployer(DeploymentConfig config, DeploymentTarget target) Real AWS by default (default credential/region chain, region fromconfig.region); redirects to a local emulator instead whentargetisDeploymentTarget.LOCALSTACK/DeploymentTarget.MINISTACKandManagerEndpointSupport.resolveLocalEmulatorEndpoint(DeploymentTarget)finds one — see class javadoc.AwsDirectDeployer(DeploymentConfig config, DeploymentTarget target, software.amazon.awssdk.auth.credentials.AwsCredentialsProvider credentialsOverride) Same asAwsDirectDeployer(DeploymentConfig, DeploymentTarget), but with an explicit credentials provider for AWS calls instead of the default chain, e.g. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidvoiddelete(String stackName, StackProgressListener listener) Same asdelete(String), additionally reporting each CloudFormation stack event tolisteneras it happens (may benullto skip live reporting).Creates or updatesstackNamefromtemplatevia a change set.deploy(String stackName, Path template, StackProgressListener listener) Same asdeploy(String, Path), additionally reporting each CloudFormation stack event tolisteneras it happens (may benullto skip live reporting).previewChangeSet(String stackName, Path template) Creates a change set forstackNamefromtemplateand returns its resource-change summary without executing it — the create-time equivalent ofcdk deploy --no-execute.static StringresolveCdkBootstrapParameters(String templateBody) CDK injectsBootstrapVersionasAWS::SSM::Parameter::Value<String>, whose default resolves from/cdk-bootstrap/hnb659fds/versionin SSM Parameter Store.booleanstackExists(String stackName) verifyDeployment(String stackName) Confirm the stack exists and return its outputs.
-
Field Details
-
TEMPLATE_BUCKET_PREFIX
Shared withManagerOperatorIamSupport's S3 grant for this bucket — keep the two in sync rather than duplicating the literal.- See Also:
-
TAG_MANAGED
- See Also:
-
TAG_APPLICATION
- See Also:
-
TAG_RUNTIME
- See Also:
-
-
Constructor Details
-
AwsDirectDeployer
Real AWS by default (default credential/region chain, region fromconfig.region); redirects to a local emulator instead whentargetisDeploymentTarget.LOCALSTACK/DeploymentTarget.MINISTACKandManagerEndpointSupport.resolveLocalEmulatorEndpoint(DeploymentTarget)finds one — see class javadoc.targetmust be the caller's own already-known, validated target (never re-derived from env vars here — see that method's own javadoc for why). Equivalent toAwsDirectDeployer(config, target, null). -
AwsDirectDeployer
public AwsDirectDeployer(DeploymentConfig config, DeploymentTarget target, software.amazon.awssdk.auth.credentials.AwsCredentialsProvider credentialsOverride) Same asAwsDirectDeployer(DeploymentConfig, DeploymentTarget), but with an explicit credentials provider for AWS calls instead of the default chain, e.g. for a caller that assumed a cross-account IAM role.nullmeans the default credential chain.Ignored when
targetresolves to a local emulator, which always uses the fixedtest/teststatic credentials.
-
-
Method Details
-
deploy
Creates or updatesstackNamefromtemplatevia a change set. No-op (returnsnoOp = true) when the stack already matches the candidate template.- Throws:
IOException
-
deploy
public AwsStackDeployResult deploy(String stackName, Path template, StackProgressListener listener) throws IOException Same asdeploy(String, Path), additionally reporting each CloudFormation stack event tolisteneras it happens (may benullto skip live reporting).- Throws:
IOException
-
previewChangeSet
Creates a change set forstackNamefromtemplateand returns its resource-change summary without executing it — the create-time equivalent ofcdk deploy --no-execute. The change set is deleted immediately after being described, so nothing in the account outlives this call; unlike the CDK CLI's own--no-execute, there's no changeset left behind to inspect or execute later, since this is a one-shot preview, not a staged deploy. No-op (returnsnoOp = true) when the stack already matches the candidate template, exactly likedeploy(String, Path).- Throws:
IOException
-
delete
- Throws:
IOException
-
delete
Same asdelete(String), additionally reporting each CloudFormation stack event tolisteneras it happens (may benullto skip live reporting).- Throws:
IOException
-
stackExists
-
outputs
-
verifyDeployment
Confirm the stack exists and return its outputs.- Throws:
IOException- when the stack is missing or outputs cannot be read
-
resolveCdkBootstrapParameters
CDK injectsBootstrapVersionasAWS::SSM::Parameter::Value<String>, whose default resolves from/cdk-bootstrap/hnb659fds/versionin SSM Parameter Store. That parameter exists in a bootstrapped AWS account but never in a local emulator or an AWS Marketplace buyer's own (never-bootstrapped) account, where CloudFormation rejects the reference ("Parameter BootstrapVersion should either have input value or default value") before creating a single resource. Applies the same rewrite asLocalStackTemplateAdapter.resolveCdkBootstrapParameters, duplicated becausecloudforge-apicannot depend oncloudforge-localstack. Called for every deploy target, not just a local emulator's -- a self-contained template must never depend on the deploying account's bootstrap state. Public soCloudForgeSynthesizer #synthesizeForMarketplacecan also apply it directly to the template file it writes to disk, not just to the in-memory body this class sends to CloudFormation -- a file meant to be uploaded to AWS Marketplace has no later deploy-time rewrite step to rely on.- Throws:
IOException
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-