pub struct Stack { /* private fields */ }Expand description
Represents a CloudFormation stack containing AWS resources and their configurations.
A Stack is the core abstraction for defining and managing AWS infrastructure.
It contains a collection of AWS resources (such as Lambda functions, S3 buckets, DynamoDB tables, etc.)
that are deployed together as a single unit in AWS CloudFormation.
§Usage
Stacks are created using the StackBuilder, which provides a fluent interface for adding resources.
Once built, a stack can be:
- Synthesized into a CloudFormation template JSON using
synth() - Deployed to AWS using the deployment utilities (
deploy)
§Example
use rusty_cdk_core::stack::StackBuilder;
use rusty_cdk_core::sqs::QueueBuilder;
let mut stack_builder = StackBuilder::new();
// Add resources to the stack
QueueBuilder::new("my-queue")
.standard_queue()
.build(&mut stack_builder);
// Build the stack
let stack = stack_builder.build().unwrap();
// Synthesize to CloudFormation template
let template_json = stack.synth().unwrap();§Serialization
The stack is serialized to CloudFormation-compatible JSON format, with:
Resources: The AWS resources mapMetadata: Additional metadata for resource management- Tags are not serialized directly
Implementations§
Source§impl Stack
impl Stack
pub fn get_assets(&self) -> Vec<Asset>
Sourcepub fn synth(&self) -> Result<String, String>
pub fn synth(&self) -> Result<String, String>
Synthesizes the stack into a CloudFormation template JSON string.
This method converts the stack and all its resources into a JSON-formatted CloudFormation template that can be deployed to AWS using the AWS CLI, SDKs, or the AWS Console.
§Returns
Ok(String)- A JSON-formatted CloudFormation template stringErr(String)- An error message if serialization fails
§Example
use rusty_cdk_core::stack::StackBuilder;
use rusty_cdk_core::sqs::QueueBuilder;
let mut stack_builder = StackBuilder::new();
// Add resources to the stack
QueueBuilder::new("my-queue")
.standard_queue()
.build(&mut stack_builder);
// Build the stack
let stack = stack_builder.build().unwrap();
// Synthesize to CloudFormation template
let template_json = stack.synth().unwrap();§Usage with AWS Tools
The synthesized template can be used with:
- AWS CLI:
aws cloudformation create-stack --template-body file://template.json - AWS SDKs: Pass the template string to the CloudFormation client
- AWS Console: Upload the template file directly
pub fn update_resource_ids_for_existing_stack( &mut self, existing_ids_with_resource_ids: HashMap<String, String>, )
Trait Implementations§
Source§impl Serialize for Stack
impl Serialize for Stack
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for Stack
impl RefUnwindSafe for Stack
impl Send for Stack
impl Sync for Stack
impl Unpin for Stack
impl UnwindSafe for Stack
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more