From 52dbdde576c72dcfd1f49ad2aa7ca481c0fc6fdf Mon Sep 17 00:00:00 2001 From: brandizzi Date: Thu, 30 Jul 2026 12:32:03 -0300 Subject: [PATCH] fix(cdk): allow Beanstalk resource discovery --- infra/cdk/README.md | 7 +++++++ infra/cdk/deploy-dev-stack.ts | 35 +++-------------------------------- 2 files changed, 10 insertions(+), 32 deletions(-) diff --git a/infra/cdk/README.md b/infra/cdk/README.md index 7b8a508..d4dab94 100644 --- a/infra/cdk/README.md +++ b/infra/cdk/README.md @@ -238,6 +238,13 @@ The next rerun cleared S3 and then required the read-only managed-stack update also required `cloudformation:CancelUpdateStack`; the cancel action is scoped to the same single stack ARN as `UpdateStack`. +The subsequent rerun progressed into Auto Scaling and required +`autoscaling:DescribeLaunchConfigurations`. Because Elastic Beanstalk's +managed update workflow performs variable resource discovery, the role follows +the documented read-only discovery families for EC2, Elastic Load Balancing, +and Auto Scaling (`Describe*`). These grants expose metadata across the account +but do not authorize any mutation; write actions remain separately scoped. + The pinned deployment action can return success after Elastic Beanstalk emits a fatal deployment event. The following workflow step therefore verifies that the exact immutable version label is active and healthy before smoke testing. diff --git a/infra/cdk/deploy-dev-stack.ts b/infra/cdk/deploy-dev-stack.ts index 107e046..6ec101d 100644 --- a/infra/cdk/deploy-dev-stack.ts +++ b/infra/cdk/deploy-dev-stack.ts @@ -43,9 +43,12 @@ export class DeployDevStack extends cdk.Stack { new iam.PolicyStatement({ effect: iam.Effect.ALLOW, actions: [ + 'autoscaling:Describe*', + 'ec2:Describe*', 'elasticbeanstalk:DescribeEnvironments', 'elasticbeanstalk:DescribeApplicationVersions', 'elasticbeanstalk:DescribeEvents', + 'elasticloadbalancing:Describe*', ], resources: ['*'], }), @@ -89,38 +92,6 @@ export class DeployDevStack extends cdk.Stack { }), ); - deployRole.addToPolicy( - new iam.PolicyStatement({ - effect: iam.Effect.ALLOW, - actions: [ - 'ec2:DescribeAvailabilityZones', - 'ec2:DescribeImages', - 'ec2:DescribeSubnets', - 'ec2:DescribeVpcs', - ], - resources: ['*'], - }), - ); - - deployRole.addToPolicy( - new iam.PolicyStatement({ - effect: iam.Effect.ALLOW, - actions: ['elasticloadbalancing:DescribeLoadBalancers'], - resources: ['*'], - }), - ); - - deployRole.addToPolicy( - new iam.PolicyStatement({ - effect: iam.Effect.ALLOW, - actions: [ - 'autoscaling:DescribeAutoScalingGroups', - 'autoscaling:DescribeScalingActivities', - ], - resources: ['*'], - }), - ); - deployRole.addToPolicy( new iam.PolicyStatement({ effect: iam.Effect.ALLOW,