New ask Hacker News story: Tell HN: Default app in AWS ElasticBeanstalk writes all POSTs to “/” to a file

Tell HN: Default app in AWS ElasticBeanstalk writes all POSTs to “/” to a file
2 by airstrike | 0 comments on Hacker News.
Per the docs at https://ift.tt/85V3hGk "Launching an environment with a sample Java application Elastic Beanstalk provides single page sample applications for each platform as well as more complex examples that show the use of additional AWS resources such as Amazon RDS and language or platform-specific features and APIs. The single page samples are the same code that you get when you create an environment without supplying your own source code. The more complex examples are hosted on GitHub and may need to be compiled or built prior to deploying to an Elastic Beanstalk environment." Importantly, if you don't provide any code for your newly created environment -- REGARDLESS of the runtime you choose --, this sample Tomcat app gets loaded, and the index.jsp reads: /** Log POSTs at / to a file **/ if ("POST".equalsIgnoreCase(request.getMethod())) { BufferedWriter writer = new BufferedWriter(new FileWriter("/tmp/sample-app.log", true)); Scanner scanner = new Scanner(request.getInputStream()).useDelimiter("\\A"); if(scanner.hasNext()) { String reqBody = scanner.next(); writer.write(String.format("%s Received message: %s.\n", (new Date()).toString(), reqBody)); } writer.flush(); writer.close(); } else { /** standard html placeholder page **/

Your first &AWS; Elastic Beanstalk Application is now running on your own dedicated environment in the &AWS; Cloud

Full index.jsp here: https://ift.tt/25dFaC9 Note that if you rely on AWS Codepipeline to deploy code to blank AWS EB environments, you will expose your environment to this default app. My logs days after starting a new EB environment for "Node.js 18 running on 64bit Amazon Linux 2023/6.0.0": https://ift.tt/DpwyF4v I haven't figured out what "Received task undefined scheduled at undefined" means, but it doesn't sound encouraging

Comments