user22104925
user22104925

Reputation: 1

Is it possible to generate binary files in AWS Lambda with the Maxmind GeoIpUpdate tool

I'm currently looking to create an AWS Lambda that takes the Maxmind GeoIpUpdate tool which is an executable file and its config file and runs the executable which generates new proprietary binary files. I want to store the new files in the Lambda /tmp directory so that I can then write them to an S3 bucket.

        val amazonS3 = AmazonS3Client.builder().build()
        val classLoader = javaClass.classLoader
        val configFile = File(classLoader.getResource("GeoIP.conf").file)
        configFile.setWritable(true, false)
        configFile.setReadable(true, false)
        val executableFile = File(classLoader.getResource("geoipupdate").file)
        executableFile.setWritable(true, false)
        executableFile.setReadable(true, false)
        executableFile.setExecutable(true, false)
        try {
            ProcessBuilder().directory(File("/var/task/"))
                .command("./geoipupdate", "-f", "GeoIP.conf", "-d", "/tmp/").start().waitFor()
        } catch (e: Exception) {
            logger.info("error: ${e.message}")
        }
        "ls -l /tmp".runCommand()

When I run this code locally and write to a desktop folder it works as it intended. When I run it in AWS Lambda, I would expect that the generated files would get written to the /tmp directory so that I could then write them to an S3 bucket but after executing the command, the /tmp directory doesn't contain the files.

Upvotes: 0

Views: 105

Answers (0)

Related Questions