Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
633 changes: 137 additions & 496 deletions crates/fakecloud-cloudformation/src/extras.rs

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions crates/fakecloud-cloudformation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ pub mod extras;
pub(crate) mod input_constraints;
pub mod resource_provisioner;
pub(crate) mod service;
pub(crate) mod stack_sets;
pub(crate) mod state;
pub mod template;
pub(crate) mod template_summary;
pub mod xml_responses;

pub use service::{CloudControlOutcome, CloudFormationDeps, CloudFormationService};
pub use stack_sets::restore_stack_sets;
pub use state::{
CloudFormationSnapshot, SharedCloudFormationState, CLOUDFORMATION_SNAPSHOT_SCHEMA_VERSION,
};
29 changes: 25 additions & 4 deletions crates/fakecloud-cloudformation/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ fn reconstruct_stack_resource(
}
}

#[derive(Clone)]
pub struct CloudFormationDeps {
pub sqs: SharedSqsState,
pub sns: SharedSnsState,
Expand Down Expand Up @@ -593,6 +594,7 @@ pub struct CloudFormationDeps {
pub kafka_runtime: Option<Arc<fakecloud_kafka::KafkaRuntime>>,
}

#[derive(Clone)]
pub struct CloudFormationService {
pub(crate) state: SharedCloudFormationState,
pub(crate) deps: CloudFormationDeps,
Expand Down Expand Up @@ -1039,7 +1041,7 @@ impl CloudFormationService {
self
}

async fn save_snapshot(&self) {
pub(crate) async fn save_snapshot(&self) {
let Some(store) = self.snapshot_store.clone() else {
return;
};
Expand Down Expand Up @@ -1658,7 +1660,10 @@ impl CloudFormationService {
Ok(())
}

async fn create_stack(&self, req: &AwsRequest) -> Result<AwsResponse, AwsServiceError> {
pub(crate) async fn create_stack(
&self,
req: &AwsRequest,
) -> Result<AwsResponse, AwsServiceError> {
let params = Self::get_all_params(req);

// `negative_omit_StackName` expects any 4xx; the AnyError expectation
Expand Down Expand Up @@ -2147,7 +2152,10 @@ impl CloudFormationService {
);
}

async fn delete_stack(&self, req: &AwsRequest) -> Result<AwsResponse, AwsServiceError> {
pub(crate) async fn delete_stack(
&self,
req: &AwsRequest,
) -> Result<AwsResponse, AwsServiceError> {
let stack_name = Self::get_param(req, "StackName").ok_or_else(|| {
AwsServiceError::aws_error(
StatusCode::BAD_REQUEST,
Expand Down Expand Up @@ -2441,7 +2449,10 @@ impl CloudFormationService {
))
}

async fn update_stack(&self, req: &AwsRequest) -> Result<AwsResponse, AwsServiceError> {
pub(crate) async fn update_stack(
&self,
req: &AwsRequest,
) -> Result<AwsResponse, AwsServiceError> {
let mut input = UpdateStackInput::from_params(req)?;

// Get stack_id before write lock for the provisioner
Expand Down Expand Up @@ -3154,7 +3165,14 @@ impl AwsService for CloudFormationService {
| "DeleteChangeSet"
| "ExecuteChangeSet"
| "CreateStackSet"
| "UpdateStackSet"
| "DeleteStackSet"
| "CreateStackInstances"
| "UpdateStackInstances"
| "DeleteStackInstances"
| "StopStackSetOperation"
| "ImportStacksToStackSet"
| "DetectStackSetDrift"
| "CreateStackRefactor"
| "CreateGeneratedTemplate"
| "DeleteGeneratedTemplate"
Expand All @@ -3172,6 +3190,9 @@ impl AwsService for CloudFormationService {
"DescribeStackResources" => self.describe_stack_resources(&req),
"UpdateStack" => self.update_stack(&req).await,
"GetTemplate" => self.get_template(&req),
a if crate::stack_sets::is_stack_set_action(a) => {
self.handle_stack_set_action(&req).await
}
_ => self.handle_extra_action(&req),
};
if mutates && matches!(result.as_ref(), Ok(resp) if resp.status.is_success()) {
Expand Down
Loading
Loading