Search code examples
amazon-web-servicesscalavariablesaws-glue

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?


Solution

  • A previous poster deleted their answer, but I was able to get this working with the following

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