简体   繁体   English

尝试传递动态变量时,值不是对象的成员

[英]Value is not a member of Object when trying to pass dynamic variable

I've got the following code我有以下代码

val region = envArgs("region")

// create a client object of class AWSSimpleSystemsManagementClient
val client: AWSSimpleSystemsManagementClient = new AWSSimpleSystemsManagementClient().withRegion(Regions.region)

Region here is a dynamic variable that's passed in the arguments of the glue job.这里的区域是一个动态变量,它在粘合作业的参数中传递。 However, with this code I get the following error但是,使用此代码,我收到以下错误

value region is not a member of object com.amazonaws.regions.Regions    
val client: AWSSimpleSystemsManagementClient = new AWSSimpleSystemsManagementClient().withRegion(Regions.region)

Obviously its just trying to find the string "region" in Regions, how can I force it to instead search for the variable?显然它只是试图在 Regions 中找到字符串“region”,我该如何强制它改为搜索变量?

以前的海报删除了他们的答案,但我能够使用以下方法解决这个问题

val client: AWSSimpleSystemsManagementClient = new AWSSimpleSystemsManagementClient().withRegion(Regions.getCurrentRegion)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将变量的值传递给bash脚本中的命令 - Pass value of the variable to a command in bash script 我们可以在执行时将动态变量传递给 aws step 函数吗? - can we pass a dynamic variable to aws step functions on execution? 是否可以将动态变量传递给process.env以获取env变量? 例如process.env ['变量名称'] - Is it possible to pass a dynamic variable to process.env, to get the env variable? For example process.env['variable name'] 使用 head_object 时为键值使用变量 - Amazon S3 Boto3 - Using a variable for the key value when using head_object - Amazon S3 Boto3 AWS Step Function - 向传递状态类型添加动态值 - AWS Step Function - Adding dynamic value to Pass state type 尝试访问 head_object 时出现 NoCredentialError - NoCredentialError when trying to access head_object 使用 CloudWatch Event:如何将 JSON Object 作为环境变量传递给 CodeBuild - Using CloudWatch Event : How to Pass JSON Object to CodeBuild as an Environment Variable 在 AWS SSM 发送命令中传递局部变量值 - Pass local variable value in AWS SSM Send Command 将变量值从 JavaScript function 传递到 SQL 查询 AWS Z04A7DA3C5B15CAD85DA1EEBB923 - Pass variable value from JavaScript function to SQL query AWS Lambda spark-shell 错误:值生成器不是 object com.amazonaws.services.s3.model.PutObjectRequest 的成员 - spark-shell error: value builder is not a member of object com.amazonaws.services.s3.model.PutObjectRequest
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM