Class AwsDirectDeployer
- All Implemented Interfaces:
AutoCloseable
Backs CloudForgeDeployment's AWS case — the direct-deploy counterpart to
LocalStackDeployer/MiniStackDeployer, minus everything specific to emulating
AWS locally (no LocalStack Cognito/RDS-secret reconciliation, no ECS-restart-after-secret-sync —
real AWS Cognito/RDS integrate through CDK's own Secrets Manager wiring and need none of
that).
Targets real AWS by default, but transparently redirects to a local emulator when
*Manager itself* is running inside one — same LOCALSTACK_ENDPOINT/
AWS_ENDPOINT_URL env-var detection LocalStackDeployer.resolveEndpoint() already uses, deliberately
mirrored here rather than left real-AWS-only — without an endpoint override, a
deploy:create click from a Manager instance hosted on LocalStack would try to reach
cloudformation.us-east-1.amazonaws.com instead of the local emulator it's actually
running against.
Every stack this deployer creates or updates is tagged with the same
cloudforge:managed/cloudforge:application/cloudforge:runtime
convention ApplicationFargateStack/ApplicationEc2Stack apply via
Tags.of(this).add(...) at synthesis time — required both for Manager's own AWS
inventory (see StackListingPolicy) and for the aws:RequestTag/
aws:ResourceTag IAM conditions ManagerOperatorIamSupport.deployStatements
scopes CreateStack/UpdateStack to. Those conditions evaluate the stack-level
Tags parameter on the CloudFormation API call itself, not any resource-level tags
already baked into the template by the CDK Tags aspect — the two are separate
CloudFormation tagging mechanisms, and only the former is what this class controls.
Not exercised against real AWS in this repo's test suite — no AWS credentials are
available in CI/dev sandboxes for that. AwsDirectDeployerTest instead points this class
at a real LocalStack instance via the injectable-client constructor (LocalStack is
CloudFormation-API-compatible), which exercises every code path except real AWS's actual
network/auth surface. Treat a real AWS deploy as the first true end-to-end validation of this
class specifically — the underlying changeset create/execute/wait sequence is otherwise a
close copy of LocalStackDeployer's, which has been exercised that way for a while.
-
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 to use for real-AWS calls instead of the default chain — e.g. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidCreates or updatesstackNamefromtemplatevia a change set.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 to use for real-AWS calls instead of the default chain — e.g. a caller that assumed a cross-account IAM role and wants this deployer to act as that principal.nullmeans "use the default credential chain," exactlyAwsDirectDeployer(DeploymentConfig, DeploymentTarget)'s only prior behavior.Ignored when
targetresolves to a local emulator — a real AssumeRole against LocalStack/MiniStack is meaningless, so the fixedtest/teststatic credentials still win in that case, unchanged from before this overload existed.
-
-
Method Details
-
deploy
Creates or updatesstackNamefromtemplatevia a change set. No-op (returnsnoOp = true) when the stack already matches the candidate template.- Throws:
IOException
-
delete
- 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
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-