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