简体   繁体   中英

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?

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM