英文:
CircleCI 2.1 : Unknown variable(s) error for variables declared in parameters
问题
我在我的工作下定义了以下内容。但当我通过 Web 用户界面运行时,所有在参数下定义的变量都显示为未知变量。这里有什么问题?
terraform_import_resources:
docker:
- image: myecrrepo/ansibleterraformpython3:tf0.12.18-1
parameters:
aws_ssoadmin_permission_set:
type: string
default: "AWSAdministratorAccess"
aws_ssoadmin_permission_set_params:
type: string
default: "arn:aws:sso:::permissionSet/xxxxxx,arn:aws:sso:::instance/ssoins-xxxx"
aws_ssoadmin_account_assignment:
type: string
default: "AWSAdministratorAccess"
aws_ssoadmin_account_assignment_params:
type: string
default: "xxxxxx"
steps:
- checkout
- attach_workspace:
at: ~/
- add_ssh_keys: *add_ssh_keys_infra_modules
- run: *infra_modules_checkout
- run:
name: Run Terraform import
command: |
. ~/.env
ansible --version
terraform --version
TAG_NAMES=`git log -1 --pretty=%B | perl -nle 'print $1 if /\((.*)\)/'`
echo $TAG_NAMES
terraform import aws_ssoadmin_permission_set.<<pipeline.parameters.aws_ssoadmin_permission_set>> <<pipeline.parameters.aws_ssoadmin_permission_set_params>>
terraform import aws_ssoadmin_account_assignment.<<pipeline.parameters.aws_ssoadmin_account_assignment>> <<pipeline.parameters.aws_ssoadmin_account_assignment_params>>
英文:
I have the below defined under my job. But when I run thru the web UI, I get Unknown variable(s) for all the variables defined under the parameter. What is wrong here?
terraform_import_resources:
docker:
- image: myecrrepo/ansibleterraformpython3:tf0.12.18-1
parameters:
aws_ssoadmin_permission_set:
type: string
default: "AWSAdministratorAccess"
aws_ssoadmin_permission_set_params:
type: string
default: "arn:aws:sso:::permissionSet/xxxxxx,arn:aws:sso:::instance/ssoins-xxxx"
aws_ssoadmin_account_assignment:
type: string
default: "AWSAdministratorAccess"
aws_ssoadmin_account_assignment_params:
type: string
default: "xxxxxx"
steps:
- checkout
- attach_workspace:
at: ~/
- add_ssh_keys: *add_ssh_keys_infra_modules
- run: *infra_modules_checkout
- run:
name: Run Terraform import
command: |
. ~/.env
ansible --version
terraform --version
TAG_NAMES=`git log -1 --pretty=%B | perl -nle 'print $1 if /\((.*)\)/'`
echo $TAG_NAMES
terraform import aws_ssoadmin_permission_set.<< pipeline.parameters.aws_ssoadmin_permission_set>> << pipeline.parameters.aws_ssoadmin_permission_set_params >>
terraform import aws_ssoadmin_account_assignment.<< pipeline.parameters.aws_ssoadmin_account_assignment >> << pipeline.parameters.aws_ssoadmin_account_assignment_params >>
答案1
得分: 0
在作业/命令的参数中,应该使用以下形式:
<< parameters.aws_ssoadmin_permission_set >>
而不是
<< pipeline.parameters.aws_ssoadmin_permission_set >>
参考文档:https://circleci.com/docs/reusing-config/#parameter-syntax
英文:
So, I found that for a parameter in a job/command it should be used as:
<< parameters.aws_ssoadmin_permission_set >>
instead of
<< pipeline.parameters.aws_ssoadmin_permission_set >>
Doc for reference: https://circleci.com/docs/reusing-config/#parameter-syntax
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论