내용으로 건너뛰기

ec2 policy for codedeploy

-1

IAM Role for EC2 instances

    ec2_role = iam.Role(
        self,
        "ec2Role",
        assumed_by=iam.ServicePrincipal("ec2.amazonaws.com"),
        managed_policies=[
            iam.ManagedPolicy.from_aws_managed_policy_name(
                "AmazonSSMManagedInstanceCore"
            ),
            iam.ManagedPolicy.from_aws_managed_policy_name(
                "AmazonEC2ReadOnlyAccess"
            ),
            iam.ManagedPolicy.from_aws_managed_policy_name(
                "AWSCodeDeployRole"
            ),

instances failed to deploy: UPDATE_ROLLBACK_COMPLETE: Resource handler returned message: "Policy arn:aws:iam::aws:policy/AWSCodeDeployRole does not exist or is not attachable. (Service: Iam, Status Code: 404, Request ID: 42ad01f3-5bed-474d-82f1-f3274ea28bf0) (SDK Attempt Count: 1)" (RequestToken: 96f3cc20-cb5e-d373-750b-0d99e687cb9e, HandlerErrorCode: NotFound)

please provide correct policy to add here to access codedeploy for ec2 by cdk

질문됨 9달 전82회 조회

1개 답변
0

Hello.

As described in the following document, depending on the IAM policy you use, you may need to include "service-role/" or "job-function/" in the name.
https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_iam/ManagedPolicy.html

Import a managed policy from one of the policies that AWS manages.
For this managed policy, you only need to know the name to be able to use it.
Some managed policy names start with “service-role/”, some start with “job-function/”, and some don’t start with anything. Include the prefix when constructing this object.

In this case, the IAM policy ARN contains "service-role/", so please set it with "service-role/" in the name.
https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AWSCodeDeployRole.html

ARN: arn:aws:iam::aws:policy/service-role/AWSCodeDeployRole

Please try it as follows:

            iam.ManagedPolicy.from_aws_managed_policy_name(
                "service-role/AWSCodeDeployRole"
            ),
전문가

답변함 9달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

관련 콘텐츠