rusty_cdk_core/iam/
dto.rs1use serde::Serialize;
2use serde_json::Value;
3use crate::{dto_methods, ref_struct};
4use crate::shared::Id;
5
6ref_struct!(RoleRef);
9
10#[derive(Debug, Serialize)]
11pub struct Role {
12 #[serde(skip)]
13 pub(crate) id: Id,
14 #[serde(skip)]
15 pub(crate) resource_id: String,
16 #[serde(skip)]
17 pub(crate) potentially_missing_services: Vec<String>,
18 #[serde(rename = "Type")]
19 pub(crate) r#type: String,
20 #[serde(rename = "Properties")]
21 pub(crate) properties: IamRoleProperties,
22}
23dto_methods!(Role);
24
25#[derive(Debug, Serialize)]
26pub struct IamRoleProperties {
27 #[serde(rename = "AssumeRolePolicyDocument")]
28 pub(crate) assumed_role_policy_document: AssumeRolePolicyDocument,
29 #[serde(rename = "ManagedPolicyArns")]
30 pub(crate) managed_policy_arns: Vec<Value>,
31 #[serde(rename = "Policies", skip_serializing_if = "Option::is_none")]
32 pub(crate) policies: Option<Vec<Policy>>,
33 #[serde(rename = "RoleName", skip_serializing_if = "Option::is_none")]
34 pub(crate) role_name: Option<String>,
35}
36
37#[derive(Debug, Serialize)]
38pub struct Policy {
39 #[serde(rename = "PolicyName")]
40 pub(crate) policy_name: String,
41 #[serde(rename = "PolicyDocument")]
42 pub(crate) policy_document: PolicyDocument,
43}
44
45#[derive(Debug, Serialize)]
46pub struct PolicyDocument {
47 #[serde(rename = "Version")]
48 pub(crate) version: String,
49 #[serde(rename = "Statement")]
50 pub(crate) statements: Vec<Statement>
51}
52
53#[derive(Debug, Serialize)]
54pub struct AssumeRolePolicyDocument {
55 #[serde(rename = "Statement")]
56 pub(crate) statements: Vec<Statement>,
57 #[serde(rename = "Version")]
58 pub(crate) version: String,
59}
60
61#[derive(Debug, Serialize)]
62pub struct Statement {
63 #[serde(rename = "Action")]
64 pub(crate) action: Vec<String>,
65 #[serde(rename = "Effect")]
66 pub(crate) effect: String,
67 #[serde(rename = "Principal", skip_serializing_if = "Option::is_none")]
68 pub(crate) principal: Option<Principal>,
69 #[serde(rename = "Resource", skip_serializing_if = "Option::is_none")]
70 pub(crate) resource: Option<Vec<Value>>,
71 #[serde(rename = "Condition", skip_serializing_if = "Option::is_none")]
72 pub(crate) condition: Option<Value>
73}
74
75#[derive(Debug, Serialize)]
76#[serde(untagged)]
77pub enum Principal {
78 Service(ServicePrincipal),
79 AWS(AWSPrincipal),
80 Custom(String),
81}
82
83#[derive(Debug, Serialize)]
84pub struct ServicePrincipal {
85 #[serde(rename = "Service")]
86 pub(crate) service: String,
87}
88
89#[derive(Debug, Serialize)]
90pub struct AWSPrincipal {
91 #[serde(rename = "AWS")]
92 pub(crate) aws: String,
93}