Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Getting error when trying to use SPC #1328

Open
rfrezino opened this issue Aug 11, 2023 · 0 comments
Open

Bug: Getting error when trying to use SPC #1328

rfrezino opened this issue Aug 11, 2023 · 0 comments

Comments

@rfrezino
Copy link

I'm trying to set policies from CDK, and I'm getting an error, the same values using webconsole works fine.

import { Account, FeatureSet, Organization, OrganizationalUnit, Policy, PolicyType } from "@pepperize/cdk-organizations";
import { Stack } from "aws-cdk-lib";

export function createOrganization(stack: Stack) {
    const organization = new Organization(stack, 'Organization', { featureSet: FeatureSet.ALL }
    );

    const ou_infrastructure = new OrganizationalUnit(stack, 'infrastructure', {
        organizationalUnitName: 'infrastructure',
        parent: organization.root,
    })

    const ou_infra_dev = new OrganizationalUnit(stack, 'infrastructure-dev', {
        organizationalUnitName: 'infrastructure-dev',
        parent: ou_infrastructure
    })

    const ou_infra_prod = new OrganizationalUnit(stack, 'infrastructure-prod', {
        organizationalUnitName: 'infrastructure-prod',
        parent: ou_infrastructure
    })

    new Account(stack, 'infrastructure-development', {
        accountName: 'infrastructure-development',
        email: '[email protected]',
        parent: ou_infra_dev
    })

    new Account(stack, 'infrastructure-production', {
        accountName: 'infrastructure-production',
        email: '[email protected]',
        parent: ou_infra_prod
    })

    organization.enablePolicyType(PolicyType.TAG_POLICY);
    organization.enablePolicyType(PolicyType.SERVICE_CONTROL_POLICY);

    const policy = new Policy(stack, "Policy", {
        content: '{\n"Version":"2012-10-17","Statement":{\n"Effect":"Deny","Action":"s3:*"\n}\n}',
        description: "Enables admins of attached accounts to delegate all S3 permissions",
        policyName: "AllowAllS3Actions",
        policyType: PolicyType.SERVICE_CONTROL_POLICY,
    });

    ou_infrastructure.attachPolicy(policy);
}

I get the error:

Received response status [FAILED] from custom resource. Message returned: The provided policy document does not meet the requirements of the specified pol
icy type. (RequestId: 3d1f559e-9123-4a99-95e1-a7778ebab168)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant