最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

amazon web services - Is CDK's auto-generated AssumeRolePolicy sufficient, or should I specify a condition for specific

programmeradmin3浏览0评论

I've been working with CDK for a bit, and haven't had any reason to modify any of the default roles/policies that are auto-generated when I create resources like lambdas or step functions. However, I also know that from a security perspective, its best practice to be as restrictive as possible for policies and permissions.

This made my wonder whether I should specify a condition in my assumeRolePolicies to only allow specific resources to assume that role. For eg, after my cdk code gets converted into yaml, is this sufficiently secure?

AssumeRolePolicyDocument:
    Version: "2012-10-17"
    Statement:
      - Effect: Allow
        Principal:
          Service:
            - lambda.amazonaws
        Action:
          - 'sts:AssumeRole'

Or would it be best practice to add a condition if I'm sure that I only want this role to be assumed by one resource, like so:

AssumeRolePolicyDocument:
    Version: "2012-10-17"
    Statement:
      - Effect: Allow
        Principal:
          Service:
            - lambda.amazonaws
        Action:
          - 'sts:AssumeRole'
        Condition:
          ArnLike:
            aws:SourceArn: myLambdaArn

And if I should add the condition, is there an easy way to do it in CDK without having to replace the resource's role.assumeRolePolicy entirely?

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论