1 | import * as cdk from '@aws-cdk/core';
|
2 | import { IConstruct } from '@aws-cdk/core';
|
3 | import { PolicyStatement } from './policy-statement';
|
4 |
|
5 |
|
6 |
|
7 | export interface PolicyDocumentProps {
|
8 | |
9 |
|
10 |
|
11 |
|
12 |
|
13 | readonly assignSids?: boolean;
|
14 | |
15 |
|
16 |
|
17 |
|
18 |
|
19 | readonly statements?: PolicyStatement[];
|
20 | |
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 | readonly minimize?: boolean;
|
37 | }
|
38 |
|
39 |
|
40 |
|
41 | export declare class PolicyDocument implements cdk.IResolvable {
|
42 | |
43 |
|
44 |
|
45 |
|
46 |
|
47 | static fromJson(obj: any): PolicyDocument;
|
48 | readonly creationStack: string[];
|
49 | private readonly statements;
|
50 | private readonly autoAssignSids;
|
51 | private readonly minimize?;
|
52 | constructor(props?: PolicyDocumentProps);
|
53 | resolve(context: cdk.IResolveContext): any;
|
54 | /**
|
55 | * Whether the policy document contains any statements.
|
56 | */
|
57 | get isEmpty(): boolean;
|
58 | /**
|
59 | * The number of statements already added to this policy.
|
60 | * Can be used, for example, to generate unique "sid"s within the policy.
|
61 | */
|
62 | get statementCount(): number;
|
63 | /**
|
64 | * Adds a statement to the policy document.
|
65 | *
|
66 | * @param statement the statement to add.
|
67 | */
|
68 | addStatements(...statement: PolicyStatement[]): void;
|
69 | /**
|
70 | * Encode the policy document as a string
|
71 | */
|
72 | toString(): string;
|
73 | /**
|
74 | * JSON-ify the document
|
75 | *
|
76 | * Used when JSON.stringify() is called
|
77 | */
|
78 | toJSON(): any;
|
79 | /**
|
80 | * Validate that all policy statements in the policy document satisfies the
|
81 | * requirements for any policy.
|
82 | *
|
83 | * @see https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html#access_policies-json
|
84 | *
|
85 | * @returns An array of validation error messages, or an empty array if the document is valid.
|
86 | */
|
87 | validateForAnyPolicy(): string[];
|
88 | /**
|
89 | * Validate that all policy statements in the policy document satisfies the
|
90 | * requirements for a resource-based policy.
|
91 | *
|
92 | * @see https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html#access_policies-json
|
93 | *
|
94 | * @returns An array of validation error messages, or an empty array if the document is valid.
|
95 | */
|
96 | validateForResourcePolicy(): string[];
|
97 | /**
|
98 | * Validate that all policy statements in the policy document satisfies the
|
99 | * requirements for an identity-based policy.
|
100 | *
|
101 | * @see https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html#access_policies-json
|
102 | *
|
103 | * @returns An array of validation error messages, or an empty array if the document is valid.
|
104 | */
|
105 | validateForIdentityPolicy(): string[];
|
106 | /**
|
107 | * Perform statement merging (if enabled and not done yet)
|
108 | *
|
109 | * @internal
|
110 | */
|
111 | _maybeMergeStatements(scope: cdk.IConstruct): void;
|
112 | /**
|
113 | * Split the statements of the PolicyDocument into multiple groups, limited by their size
|
114 | *
|
115 | * We do a round of size-limited merging first (making sure to not produce statements too
|
116 | * large to fit into standalone policies), so that we can most accurately estimate total
|
117 | * policy size. Another final round of minimization will be done just before rendering to
|
118 | * end up with minimal policies that look nice to humans.
|
119 | *
|
120 | * Return a map of the final set of policy documents, mapped to the ORIGINAL (pre-merge)
|
121 | * PolicyStatements that ended up in the given PolicyDocument.
|
122 | *
|
123 | * @internal
|
124 | */
|
125 | _splitDocument(scope: IConstruct, selfMaximumSize: number, splitMaximumSize: number): Map<PolicyDocument, PolicyStatement[]>;
|
126 | private render;
|
127 | private shouldMerge;
|
128 | }
|