All Projects → iann0036 → aws-leastprivilege

iann0036 / aws-leastprivilege

Licence: MIT license
Generates an IAM policy for the CloudFormation service role that adheres to least privilege.

Programming Languages

python
139335 projects - #7 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to aws-leastprivilege

go-localstack
Go Wrapper for using localstack
Stars: ✭ 56 (-34.12%)
Mutual labels:  cloudformation, iam
Awesome Aws
A curated list of awesome Amazon Web Services (AWS) libraries, open source repos, guides, blogs, and other resources. Featuring the Fiery Meter of AWSome.
Stars: ✭ 9,895 (+11541.18%)
Mutual labels:  cloudformation, iam
cloudformation-checklist
The checklist for meticulous AWS DevOps engineers
Stars: ✭ 68 (-20%)
Mutual labels:  cloudformation
cloudniite
AWS Lambda Optimization and Monitoring Tool
Stars: ✭ 25 (-70.59%)
Mutual labels:  cloudformation
privx-on-aws
PrivX - Just-in-time Access Management
Stars: ✭ 18 (-78.82%)
Mutual labels:  iam
CloudGenesis
Automation for deploying & deleting CloudFormation stacks sourced from a Git repo
Stars: ✭ 34 (-60%)
Mutual labels:  cloudformation
aws-cloudformation-simplified
AWS CloudFormation - Simplified | Hands On Learning !!
Stars: ✭ 51 (-40%)
Mutual labels:  cloudformation
aws-cfn-custom-resource-lambda-edge
🏗 AWS CloudFormation custom resource that allows deploying Lambda@Edge from any region
Stars: ✭ 19 (-77.65%)
Mutual labels:  cloudformation
AWSlack
Get Slack notifications on AWS CloudWatch events
Stars: ✭ 21 (-75.29%)
Mutual labels:  cloudformation
gtoken
Securely access AWS services from GKE cluster
Stars: ✭ 43 (-49.41%)
Mutual labels:  iam
iam-role-injector
Assumes an IAM role via awscli STS call, injecting temporary credentials into shell environment
Stars: ✭ 27 (-68.24%)
Mutual labels:  iam
serverless-rules
Compilation of rules to validate infrastructure-as-code templates against recommended practices for serverless applications.
Stars: ✭ 352 (+314.12%)
Mutual labels:  cloudformation
typeformation
Type Cloudformation templates with pleasure!
Stars: ✭ 16 (-81.18%)
Mutual labels:  cloudformation
terraform-aws-frontend
Collection of Terraform modules for frontend app deployment on AWS.
Stars: ✭ 31 (-63.53%)
Mutual labels:  iam
mod authnz jwt
An authentication module for Apache httpd using JSON Web Tokens
Stars: ✭ 74 (-12.94%)
Mutual labels:  iam
riam
AWS IAM inspired policy engine in Rust
Stars: ✭ 19 (-77.65%)
Mutual labels:  iam
bora
A Ruby command line tool and rake tasks for working with cloudformation stacks and cfndsl
Stars: ✭ 18 (-78.82%)
Mutual labels:  cloudformation
takomo
Organize, parameterize and deploy your CloudFormation stacks
Stars: ✭ 27 (-68.24%)
Mutual labels:  cloudformation
aws-maven-plugin
Deploys resources to AWS using maven
Stars: ✭ 25 (-70.59%)
Mutual labels:  cloudformation
Transformer-ocr
Handwritten text recognition using transformers.
Stars: ✭ 92 (+8.24%)
Mutual labels:  iam

CloudFormation Service Role Generator

🚧 WORK IN PROGRESS

Generates an IAM policy for the CloudFormation service role that adheres to least privilege.

Installation

pip3 install cfnlp

Usage

Basic Examples

$ cfnlp -i test.yaml

{
    "PolicyName": "root",
    "PolicyDocument": {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Sid": "AccessAnalyzer-Create1-reg",
                "Effect": "Allow",
                "Action": [
                    "access-analyzer:TagResource",
                    "access-analyzer:CreateAnalyzer"
                ],
                "Resource": "*"
            },
            {
                "Sid": "AccessAnalyzer-Delete1-reg",
                "Effect": "Allow",
                "Action": "access-analyzer:DeleteAnalyzer",
                "Resource": "*"
            },
            {
                "Sid": "LambdaFunction-Create1",
                "Effect": "Allow",
                "Action": "lambda:CreateFunction",
                "Resource": "arn:aws:lambda:us-east-1:123456789012:function:*"
            },
            {
                "Sid": "LambdaFunction-Create2",
                "Effect": "Allow",
                "Action": "iam:PassRole",
                "Resource": "arn:aws:iam::123456789012:role/S3Access",
                "Condition": {
                    "StringEquals": {
                        "iam:PassedToService": "lambda.amazonaws.com"
                    }
                }
            },
            ...
        ]
    }
}
$ cfnlp --stack-name mystack

{
    "PolicyName": "root",
    "PolicyDocument": {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Sid": "myresource-Create1-reg",
                "Effect": "Allow",
                "Action": "ec2:ImportKeyPair",
                "Resource": "*"
            }
            ...
        ]
    }
}

Options

The following command line arguments are available:

-i, --input-filename

The filename of a local CloudFormation template file to analyze. You must specify either this option or --stack-name.

--stack-name

The stack name or stack ID of a deployed CloudFormation stack to analyze. You must specify either this option or -i, --input-filename.

--include-update-actions

When specified, actions relating to stack updates (that don't trigger a resource replacement) will be included in the output if a value for its property has been set. The default behaviour will not include the actions for stack updates.

--consolidate-policy

When specified, the Sid fields will be removed and statements sharing the same attributes except Action will be combined.

--region

Overrides the region to specify in policy outputs and when retrieving deployed templates. By default, the region will be retrieved using the default precedence for Boto3.

--profile

When specified, the specified named profile credentials will be used for all data gathering AWS actions. The AWS_PROFILE environmental variable would also be respected if this property is not set.

Policy Generation Logic

Policies will be created with data following the below preference:

  1. Per-type mappings created by incrementally increasing required permissions
  2. Permissions retrieved from the CloudFormation Registry
  3. No data available (a warning will be shown for missed types)

For supported per-type mapping resources

The generated policy will be as specific as possible when specifying actions, resources and conditions. Wildcard actions are never used and all conditions that are available will be populated unless:

  • The condition would take no effect or there is not enough information to specify the condition, or
  • The condition is a global condition, or
  • The condition applies to an update statement and would prevent the field from being freely changed, or
  • The condition relates to the tag keys/values

Resources may be fully or partially wildcarded however will be as specific as possible.

Update statements are disabled by default. If enabled with the --include-update-actions option, only properties that have a value specified in the template will have an associated update statement that allows that value to be changed. Permissions required to add new properties may not have the permissions included in the policy.

For permissions retrieved from the CloudFormation Registry

The generated policy will only include the actions specified in the resource type specification provided by the registry. All resources will be wildcarded and no conditions will apply.

Supported Resource Types

The following resource types are supported with a per-type mapping:

  • AWS::CloudWatch::Alarm
  • AWS::EC2::Instance
  • AWS::EC2::SecurityGroup
  • AWS::EC2::Subnet
  • AWS::EC2::VPC
  • AWS::IAM::Role
  • AWS::Lambda::Function
  • AWS::Lambda::Version
  • AWS::Route53::HostedZone
  • AWS::S3::Bucket
  • AWS::SNS::Topic
  • AWS::SQS::Queue
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].