export function iamPolicy(policyDocument) { return policyDocument; }
export class Policy {
    document;
    constructor(document = { statement: [], version: "2012-10-17" }) {
        this.document = document;
    }
    grant(action, effect, onResource) {
        this.document.statement = [
            ...(this.document.statement ?? []),
            { action, effect, resource: onResource }
        ];
        return this;
    }
    allow(action, onResource) {
        return this.grant(action, 'Allow', onResource);
    }
    deny(action, onResource) {
        return this.grant(action, 'Deny', onResource);
    }
    static allow(action, onResource) {
        return new Policy().allow(action, onResource);
    }
    static deny(action, onResource) {
        return new Policy().deny(action, onResource);
    }
}
export class Iam {
    roleLike;
    constructor(roleLike) {
        this.roleLike = roleLike;
    }
    add(policyName, policy) {
        this.roleLike.properties.policies = [
            ...(this.roleLike.properties.policies ?? []),
            { policyName, policyDocument: policy.document }
        ];
        return this;
    }
    withManagedPolicies(...arns) {
        this.roleLike.properties.managedPolicyArns = arns;
        return this;
    }
    static policy(creator) {
        return creator();
    }
    static from(roleLike) {
        return new Iam(roleLike);
    }
}
