Skip to main content

fakecloud_cloudformation/
state.rs

1use chrono::{DateTime, Utc};
2use parking_lot::RwLock;
3use std::collections::HashMap;
4use std::sync::Arc;
5
6#[derive(Debug, Clone)]
7pub struct StackResource {
8    pub logical_id: String,
9    pub physical_id: String,
10    pub resource_type: String,
11    pub status: String,
12}
13
14#[derive(Debug, Clone)]
15pub struct Stack {
16    pub name: String,
17    pub stack_id: String,
18    pub template: String,
19    pub status: String,
20    pub resources: Vec<StackResource>,
21    pub parameters: HashMap<String, String>,
22    pub tags: HashMap<String, String>,
23    pub created_at: DateTime<Utc>,
24    pub updated_at: Option<DateTime<Utc>>,
25    pub description: Option<String>,
26}
27
28pub struct CloudFormationState {
29    pub account_id: String,
30    pub region: String,
31    pub stacks: HashMap<String, Stack>,
32}
33
34impl CloudFormationState {
35    pub fn new(account_id: &str, region: &str) -> Self {
36        Self {
37            account_id: account_id.to_string(),
38            region: region.to_string(),
39            stacks: HashMap::new(),
40        }
41    }
42
43    pub fn reset(&mut self) {
44        self.stacks.clear();
45    }
46}
47
48pub type SharedCloudFormationState = Arc<RwLock<CloudFormationState>>;