Skip to main content

This CDK Construct helps create IAM Managed Policies and IAM Roles using JSON Configuration

Project description

CDK IAM Generator

AWS CDK construct helps create IAM Managed Policies and IAM Roles using JSON Configuration

This package is written in TypeScript and made available via JSII to all other supported languages. Package are available on:

  • npm
  • [PyPI] Work in Progress.
  • [GitHub packages for Java][Maven] Work in Progress.

Quickstart

Install or update from npm

TypeScript/Javascript

npm i cdk-iamgenerator

Usage

** TypeScript **

# Example automatically generated. See https://github.com/aws/jsii/issues/826
from cdk_iam_generator import IamPolicyGenerator, IamRoleGenerator

IamPolicyGenerator(self, "IamPolicyGenerator",
    config_path="config/iam_generator_config.json",
    policy_path="config/policy"
)

IamRoleGenerator(self, "IamRoleGenerator",
    config_path="config/iam_generator_config.json"
)

Prerequsites

Example: Place all the Policy Json files inside config/policy in your project root and policy file would look something like this:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "codecommit:CancelUploadArchive",
        "codecommit:UploadArchive"
      ],
      "Resource": "*"
    }
  ]
}

Configure the policies and roles to be created in config/iam_generator_config.json file and would look something like this:

{
    "policies": [
        {
            "policy_name": "CodeCommitArchive",
            "description": "CodeCommitArchive policy",
            "policy_file": "CodeCommitArchive.json"
        },
        {
            "policy_name": "KMSPolicy",
            "description": "KMSPolicy policy",
            "policy_file": "KMSPolicy.json"
        },
        {
            "policy_name": "CreateServiceLinkedRoleECS",
            "description": "CreateServiceLinkedRoleECS policy",
            "policy_file": "CreateServiceLinkedRoleECS.json"
        },
        {
            "policy_name": "DeployService1",
            "description": "DeployService1 policy",
            "policy_file": "DeployService1.json"
        },
        {
            "policy_name": "DeployService2",
            "description": "DeployService2 policy",
            "policy_file": "DeployService2.json"
        }
    ],
    "roles": [
        {
            "role_name": "TestRole1",
            "trust_service_principal": ["apigateway.amazonaws.com","lambda.amazonaws.com"],
            "customer_managed_policies": ["DeployService1","DeployService2","KMSPolicy"],
            "aws_managed_policies": ["service-role/AmazonAPIGatewayPushToCloudWatchLogs"]
        },
        {
            "role_name": "TestRole2",
            "trust_service_principal": ["sns.amazonaws.com"],
            "trust_account_principal": ["748669239283"],
            "customer_managed_policies": ["CreateServiceLinkedRoleECS","CodeCommitArchive","KMSPolicy"],
            "aws_managed_policies": ["service-role/AmazonAPIGatewayPushToCloudWatchLogs"]
        },
        {
            "role_name": "TestRole3",
            "trust_service_principal": ["ec2.amazonaws.com","sns.amazonaws.com"],
            "trust_account_principal": ["748669239283"],
            "customer_managed_policies": ["DeployService2","CodeCommitArchive","KMSPolicy"],
            "aws_managed_policies": ["AWSLambdaFullAccess"]
        }

    ]
}

License

cdk-iamgenerator is distributed under the Apache License, Version 2.0.

See LICENSE for more information.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cdk-iamgenerator-1.0.1.tar.gz (19.7 kB view details)

Uploaded Source

File details

Details for the file cdk-iamgenerator-1.0.1.tar.gz.

File metadata

  • Download URL: cdk-iamgenerator-1.0.1.tar.gz
  • Upload date:
  • Size: 19.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.6

File hashes

Hashes for cdk-iamgenerator-1.0.1.tar.gz
Algorithm Hash digest
SHA256 6b3a5087f5a0d0670da276a88ee73b14bca729df22d8a756ac7de10ea6b4334a
MD5 370c9c4b2b39ecdfa2f3622b618b4b87
BLAKE2b-256 6222a78d21075e7babb4deac00287f51e8544a0d52fcdb148fe3e71fd0756380

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page