Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reading object in s3 bucket from ecs fargate task #9

Open
1 of 3 tasks
Ada-Nick opened this issue Jun 26, 2021 · 3 comments
Open
1 of 3 tasks

Reading object in s3 bucket from ecs fargate task #9

Ada-Nick opened this issue Jun 26, 2021 · 3 comments

Comments

@Ada-Nick
Copy link

Please specify whether your issue is about:

  • a possible bug
  • a question about package functionality
  • a suggested code or documentation change, improvement to the code, or feature request

I have a shiny app running on an ecs fargate task using the rocker:shiny-verse base docker image. I can't read an s3 file
within the initialisation of the shiny app (global.R file). Interestingly it does work when I change the method of serving the app in the docker file.

The docker command that works is:

CMD ["R", "-e", "shiny::runApp('/srv/shiny-server/my_app', 3838, host='0.0.0.0')"]

And the method I want to use but doesn't work:

CMD ["/usr/bin/shiny-server.sh"]

What is the intended method of accessing the permissions granted to the IAM role, how can I read from the s3 bucket within an ecs fargate task?

My global.R file looks like this:

## load package
library(ini)
library("aws.ec2metadata")

Sys.setenv("AWS_DEFAULT_REGION" = "eu-west-2")
if (is_ecs() == T) {
   metadata$iam_role("ecsTaskExecutionRole")
}

config = aws.s3::s3read_using(read.ini,
                              object = 'my_object.ini',
                              bucket = 'my_bucket')

I can't get the session Info of the Fargate task or any logs but know it's the s3 connection that is failing as removing the
s3_read_using() call allows the app to run as expected. I have also double checked that the ecsTaskExecutionRole has s3 read
permissions required. The bucket also definitely exists and as does the object and it's in the correct region (eu-west-2).

@ghost
Copy link

ghost commented Jan 12, 2022

@Ada-Nick I'm facing the same problem today. Did you fix this with some strategy?

@Ada-Nick
Copy link
Author

Ada-Nick commented Jan 12, 2022

Yeah I did. I changed my shiny-server.sh file to this:

#!/bin/sh

# Make sure the directory for individual app logs exists
mkdir -p /var/log/shiny-server
chown shiny.shiny /var/log/shiny-server

if [ "$APPLICATION_LOGS_TO_STDOUT" != "false" ];
then
    # push the "real" application logs to stdout with xtail in detached mode
    exec xtail /var/log/shiny-server/ &
fi

env > /home/shiny/.Renviron
chown shiny.shiny /home/shiny/.Renviron

# start shiny server
exec shiny-server 2>&1

Hopefully that works for you

@ghost
Copy link

ghost commented Jan 13, 2022

@Ada-Nick That really helped here!
Thank you so much, my friend!
Greetings from Brazil =)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant