pub async fn deploy(
name: StringWithOnlyAlphaNumericsAndHyphens,
stack: Stack,
print_progress: bool,
) -> Result<String, DeployError>Expand description
Deploys a stack to AWS using CloudFormation.
This function handles the complete deployment lifecycle:
- Uploading Lambda function assets to S3
- Creating or updating the CloudFormation stack
- Monitoring deployment progress
It returns a Result. In case of error, a DeployError is returned.
For a deployment method that shows updates and exits on failure, see deploy
§Parameters
name- The CloudFormation stack name (alphanumeric characters and hyphens only)stack- The stack to deploy, created usingStackBuilderprint_progress- Print progress updates to standard out
§Tags
If tags were added to the stack using StackBuilder::add_tag(), they will be
applied to the CloudFormation stack and propagated to resources where supported.
§Example
use rusty_cdk::deploy;
use rusty_cdk::stack::StackBuilder;
use rusty_cdk::sqs::QueueBuilder;
use rusty_cdk_macros::string_with_only_alphanumerics_and_hyphens;
use rusty_cdk::wrappers::StringWithOnlyAlphaNumericsAndHyphens;
#[tokio::main]
async fn main() {
let mut stack_builder = StackBuilder::new();
QueueBuilder::new("my-queue")
.standard_queue()
.build(&mut stack_builder);
let stack = stack_builder.build().expect("Stack to build successfully");
let result = deploy(string_with_only_alphanumerics_and_hyphens!("my-application-stack"), stack, false).await;
}§AWS Credentials
This function requires valid AWS credentials configured through:
- Environment variables (
AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY) - AWS credentials file (
~/.aws/credentials) - IAM role (when running on EC2, ECS, Lambda, etc.)
- …
The AWS credentials must have permissions for:
cloudformation:CreateStackcloudformation:UpdateStackcloudformation:DescribeStackscloudformation:GetTemplates3:PutObject(if you have Lambdas)- IAM permissions for creating roles
- Service-specific permissions for resources being created