aws / aws/aws-toolkit-azure-devops

AWS LambdaDeployFunction task succeeds without updating environment variables under specific conditions

Open
#613 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
258
Forks
114
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**

The AWS Lambda Deploy Function task (v1.24.0) allows environment variables to be deployed to Lambda functions without raising an error when the service connection principal lacks required KMS permissions if using encrypted environment variables. The task completes successfully, giving the false impression that environment variables were updated, when in reality they fail to apply silently. Additionally, the task documentation does not list KMS permissions as a requirement.

**To reproduce**

1. Create an AWS service connection with Lambda management permissions (`lambda:UpdateFunctionConfiguration`, `lambda:UpdateFunctionCode`, etc.) but without KMS permissions
2. Use AWS Lambda Deploy Function task to deploy a Lambda function with environment variables and other config, such as VPC settings specified
3. Task completes with success status and no error or warning messages
4. Verify on the Lambda function: VPC config/security groups/code updates apply correctly, but environment variables do not update
5. When configuring environment variables with the AWS Lambda Deploy Function task, the service connection principal required the following KMS permissions:

- `kms:Encrypt`
- `kms:Decrypt`
- `kms:DescribeKey`
- `kms:CreateGrant`

These permissions were not listed in the task documentation and were only discovered through trial and error when the task began surfacing KMS-related errors after partial permissions were granted.

**Expected behavior**

The task should either:
1. **Fail with a clear, upfront error message** indicating that KMS permissions (`kms:Encrypt`, `kms:Decrypt`, `etc..`) are required to set/update environment variables, before attempting the deployment, OR
2. **The documentation should be updated** to list `kms:Encrypt` and `kms:Decrypt` as required task permissions when environment variables are being configured

**Screenshots**

N/A

**Your Environment**

- On-prem or cloud based?: Cloud (Azure DevOps)
- Azure DevOps version: Latest
- AWS Toolkit for Azure DevOps version: 1.24.0

**Additional context**

- We realized the KMS permission was the issue after converting our pipeline to use the AWS Shell Script task instead, which also showed successful deployment but its output clearly showed the reason for failed environment variable updates:
```
Environment": {
"Error": {
"ErrorCode": "AccessDeniedException",
"Message": "Lambda was unable to decrypt your environment variables because the KMS access was denied. Please check your KMS permissions. KMS Exception: AccessDeniedException KMS Message: User: arn:aws:iam::#############:user/############### is not authorized to perform: kms:Decrypt on resource: arn:aws:kms:us-east-1:#############:key/####################### because no identity-based policy allows the kms:Decrypt action"
}
},
```

- Without any KMS permissions, the task succeeds silently and does not indicate that environment variable updates failed
- The task only surfaces KMS permission errors after partial permissions are granted, suggesting the task does not validate KMS permissions upfront
- Current task documentation at https://docs.aws.amazon.com/vsts/latest/userguide/lambda-deploy.html#task-permissions does not list KMS permissions as required, leading to confusion
- This is a significant operational issue because deployments appear successful when critical configuration (e.g. database credentials in environment variables) fails to apply

Contributor guide

Open the contributing guide

Research direction

Start with the AWS Lambda Deploy Function task and its task-permissions documentation at the linked AWS page. Reproduce deployment with environment variables and missing KMS permissions, then determine whether the accepted fix is clear failure reporting or documenting the required permissions; done means the task no longer reports success when variables fail to apply, or the requirements are accurately documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.