我在 Azure DevOps 上的 git 中有一个 Nodejs 应用程序。我正在使用 AWS toolkit for Azure DevOps 部署到 AWS elastic beanstalk,并使用其中的 2 个任务,首先使用任务 BeanstalkCreateApplicationVersion 创建新的应用程序版本,然后使用任务 BeanstalkDeployApplication 部署该版本。下面是我用来首先将文件上传到 s3、创建版本然后部署它的配置:
- task: BeanstalkCreateApplicationVersion@1
inputs:
awsCredentials: 'AWS'
regionName: 'eu-west-2'
applicationName: 'test'
applicationType: 's3'
deploymentBundleBucket: 'azure-devops-s3'
deploymentBundleKey: 'app/$(Build.BuildId).zip'
versionLabel: '$(Build.BuildId)'
outputVariable: '$(VersionLabelOutput)'
- task: BeanstalkDeployApplication@1
inputs:
awsCredentials: 'AWS'
regionName: 'eu-west-2'
applicationName: 'test'
environmentName: 'test-env'
applicationType: 'version'
versionLabel: '$(Build.BuildId)'
outputVariable: '$(VersionLabelOutput)'
运行时,到 s3 的 zip 文件上传正常,在应用程序版本页面中创建了一个新版本,我可以在 AWS EB 应用程序中看到它。但是,当部署任务运行时,我收到错误:
##[error]Error: Environment test-env does not exist for the application test
完整错误日志:
2024-05-27T21:48:58.1337210Z ==============================================================================
2024-05-27T21:48:58.6835860Z Deployment type set to version
2024-05-27T21:48:58.6845889Z Configuring credentials for task
2024-05-27T21:48:58.6857862Z ...configuring AWS credentials from service endpoint 'fdcf7bc7-ef55-447f-b7ca-405078d3c310'
2024-05-27T21:48:58.6873904Z ...configuring AWS credentials from service endpoint 'fdcf7bc7-ef55-447f-b7ca-405078d3c310'
2024-05-27T21:48:58.6874246Z ...endpoint defines standard access/secret key credentials
2024-05-27T21:48:58.6880524Z Configuring region for task
2024-05-27T21:48:58.6881133Z ...configured to use region eu-west-2, defined in task.
2024-05-27T21:48:58.6958867Z Configuring credentials for task
2024-05-27T21:48:58.6959889Z ...configuring AWS credentials from service endpoint 'fdcf7bc7-ef55-447f-b7ca-405078d3c310'
2024-05-27T21:48:58.6963463Z ...configuring AWS credentials from service endpoint 'fdcf7bc7-ef55-447f-b7ca-405078d3c310'
2024-05-27T21:48:58.6963902Z ...endpoint defines standard access/secret key credentials
2024-05-27T21:48:58.6964573Z Configuring region for task
2024-05-27T21:48:58.6967920Z ...configured to use region eu-west-2, defined in task.
2024-05-27T21:48:59.0247976Z ##[error]Error: Environment test-env does not exist for the application test
2024-05-27T21:48:59.0284495Z ##[section]Finishing: BeanstalkDeployApplication
这些是我在 Azure DevOps 管道的 IAM 用户中使用的权限:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"autoscaling:ResumeProcesses",
"s3:*",
"cloudformation:DescribeStackResources",
"cloudformation:DescribeStackResource",
"autoscaling:SuspendProcesses",
"elasticbeanstalk:CreateApplicationVersion",
"elasticbeanstalk:CreateStorageLocation",
"elasticbeanstalk:DescribeEvents",
"autoscaling:DescribeScalingActivities",
"autoscaling:DescribeAutoScalingGroups",
"elasticbeanstalk:UpdateEnvironment",
"elasticbeanstalk:DescribeApplications",
"elasticloadbalancing:RegisterInstancesWithLoadBalancer"
],
"Resource": "*"
}
]
}
问题是 IAM 用户缺少
elasticbeanstalk:DescribeEnvironments
的权限。
添加后,部署再次开始工作,问题得到解决。