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

Add tag based authorization for CW Logs #9

Closed
kalleeh opened this issue Jul 8, 2019 · 8 comments
Closed

Add tag based authorization for CW Logs #9

kalleeh opened this issue Jul 8, 2019 · 8 comments
Assignees
Labels
enhancement New feature or request

Comments

@kalleeh
Copy link
Owner

kalleeh commented Jul 8, 2019

Right now CloudWatch Log Groups doesn't get tags inherited from their CloudFormation stags.
CW Logs doesn't support tag based authorization either.

Currently the Cognito IAM Roles inherited by users through Cognito Groups can read from any log group but when this is added we could easily tag the log groups and then modify the IAM Role that cognito users assume to add tag based authorization to their respective log group similar to CFN templates etc.

https://docs.aws.amazon.com/IAM/latest/UserGuide/access_tags.html

{
    "Effect": "Allow",
    "Action": [
        "logs:FilterLogEvents"
    ],
    "Resource": "arn:aws:logs:[region]:[account-id]:log-group:*",
    "Condition": {
        "StringEquals": {"ec2:ResourceTag/gureume-groups": "team1"}
    }
}
@kalleeh kalleeh added the enhancement New feature or request label Jul 8, 2019
@kalleeh
Copy link
Owner Author

kalleeh commented Jul 8, 2019

*** this is not supported by AWS as of today ***

@kalleeh
Copy link
Owner Author

kalleeh commented Jul 29, 2019

This can be implemented using tagging on Log Groups now, however it isn't supported by CloudFormation. Would need to implement tag-management after stack creation or update.

Policy to support tag based authorization for the IAM roles.

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Action": [
                "logs:FilterLogEvents"
            ],
            "Effect": "Allow",
            "Resource": "arn:aws:logs:eu-west-1:[AWS-ACCOUNT-ID]:log-group:*",
            "Condition": {
                "StringLike": {
                    "logs:ResourceTag/gureume-groups": "${aws:PrincipalTag/gureume-groups}"
                }
            }
        },
        {
            "Effect": "Allow",
            "Action": "codecommit:*",
            "Resource": "*",
            "Condition": {
                "StringEquals": {
                    "aws:ResourceTag/gureume-groups": "${aws:PrincipalTag/gureume-groups}"
                }
            }
        }
    ]
}```

@kalleeh kalleeh self-assigned this Aug 9, 2019
@kalleeh
Copy link
Owner Author

kalleeh commented Aug 12, 2019

Optimized policy that only requires one statement and can then include multiple actions.
CloudWatch Log Groups cannot be tagged through CloudFormation so this needs to be done through the API.

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "codecommit:*",
                "logs:FilterLogEvents"
            ],
            "Resource": "*",
            "Condition": {
                "StringEquals": {
                    "aws:ResourceTag/gurum-groups": "${aws:PrincipalTag/gurum-groups}"
                }
            }
        }
    ]
}

@kalleeh
Copy link
Owner Author

kalleeh commented Oct 23, 2019

Task that needs to be done is to automatically tag the log group with the right group tag since CloudFormation doesn't support this yet.
Authorization is tested and works if using the CLI/API to set the tags on the LogGroup post creation.
aws logs tag-log-group

@kalleeh
Copy link
Owner Author

kalleeh commented Nov 13, 2019

Postponing until CloudFormation adds tag support for CloudWatch Log Groups.

@kalleeh
Copy link
Owner Author

kalleeh commented Jan 2, 2020

For now could add something like this to propagate tags from the CFN stack automatically.
https://serverlessrepo.aws.amazon.com/applications/arn:aws:serverlessrepo:us-east-1:374852340823:applications~propagate-cfn-tags

@kalleeh
Copy link
Owner Author

kalleeh commented Jan 20, 2020

Add documentation for current process using CFN tag propagation

@kalleeh
Copy link
Owner Author

kalleeh commented Feb 7, 2020

Closing this since it's "solved" by using a helper tagging function.
Tracked in kalleeh/gurum-products#12 to change to native CloudFormation tagging when supported.

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

No branches or pull requests

1 participant