1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
use dashmap::DashMap;
use std::collections::HashMap;
/// CloudFormation state — per account+region.
#[derive(Debug, Default)]
pub struct CloudFormationState {
pub stacks: DashMap<String, Stack>,
/// stack name → HashMap<tag key, tag value> (for TagResource/UntagResource)
pub stack_tags: DashMap<String, HashMap<String, String>>,
}
#[derive(Debug, Clone)]
pub struct Stack {
pub stack_id: String,
pub stack_name: String,
pub template_body: String,
pub parameters: HashMap<String, String>,
pub tags: HashMap<String, String>,
/// e.g. CREATE_COMPLETE, UPDATE_COMPLETE, DELETE_COMPLETE, ROLLBACK_COMPLETE
pub status: String,
pub status_reason: Option<String>,
pub resources: Vec<StackResource>,
pub events: Vec<StackEvent>,
pub change_sets: HashMap<String, ChangeSet>,
pub created_at: String,
pub updated_at: Option<String>,
pub outputs: HashMap<String, StackOutput>,
/// When true, DeleteStack returns ValidationError until the caller
/// flips it off via UpdateTerminationProtection. Mirrors AWS's
/// stack-level safeguard against accidental deletes.
pub termination_protection: bool,
/// SNS topic ARNs that receive a `cloudformation:StackEvent`
/// notification on every stack-status transition. AWS supports
/// up to 5 ARNs; we accept the same upper bound.
pub notification_arns: Vec<String>,
/// `DO_NOTHING` | `ROLLBACK` | `DELETE`. AWS's default is
/// `ROLLBACK`. The simulator never fails CreateStack, so this is
/// stored verbatim for describe round-trip and consulted by the
/// rollback path when (future) failures are wired up.
pub on_failure: String,
/// Optional stack policy document (JSON). When set, UpdateStack
/// evaluates each resource change against it and blocks updates
/// the policy denies. AWS surfaces this as `ValidationError`.
pub stack_policy_body: Option<String>,
}
#[derive(Debug, Clone)]
pub struct StackResource {
pub logical_resource_id: String,
pub physical_resource_id: Option<String>,
pub resource_type: String,
pub resource_status: String,
pub resource_status_reason: Option<String>,
pub timestamp: String,
/// `Delete` (default), `Retain`, `Snapshot`, or
/// `RetainExceptOnCreate`. Drives DeleteStack behavior; AWS keeps
/// retained resources around as the stack moves to DELETE_COMPLETE
/// and surfaces them with `DELETE_SKIPPED` status.
pub deletion_policy: Option<String>,
}
#[derive(Debug, Clone)]
pub struct StackEvent {
pub event_id: String,
pub stack_id: String,
pub stack_name: String,
pub logical_resource_id: String,
pub physical_resource_id: Option<String>,
pub resource_type: String,
pub timestamp: String,
pub resource_status: String,
pub resource_status_reason: Option<String>,
}
#[derive(Debug, Clone)]
pub struct ChangeSet {
pub change_set_id: String,
pub change_set_name: String,
pub stack_id: String,
pub stack_name: String,
pub template_body: Option<String>,
pub parameters: HashMap<String, String>,
pub status: String,
pub status_reason: Option<String>,
pub changes: Vec<Change>,
pub created_at: String,
}
#[derive(Debug, Clone)]
pub struct Change {
pub action: String,
pub logical_resource_id: String,
pub resource_type: String,
/// `True`, `False`, or `Conditional` — only set for `Modify`
/// actions. AWS computes this from per-resource-type property
/// metadata; AWSim uses a conservative heuristic (any non-tag
/// property change implies replacement) since the simulator
/// doesn't carry the per-resource property schema.
pub replacement: Option<String>,
/// Scope of the change: any combination of `Properties`,
/// `Metadata`, `Tags`, `CreationPolicy`, `UpdatePolicy`, and
/// `DeletionPolicy`. Empty for `Add` / `Remove` actions, since
/// AWS leaves Scope null in those cases.
pub scope: Vec<String>,
}
#[derive(Debug, Clone)]
pub struct StackOutput {
pub output_key: String,
pub output_value: String,
pub description: Option<String>,
}