Lets start by creating a cluster. Cluster
- Go to the Amazon ECS service page. Click clusters to create a new cluster.
Give your cluster what ever name you like
We leave other options as default.
Scroll to the bottom and click create
- Creating Task Definition
Click task definitions
on the left menu.
On the task definition screen click on create new task definition
We will use an already built docker image on Amazon ECR (Elastic Container Registry) to save time. link to git page of the streamlit app code
Under Container 1
use the public image URI public.ecr.aws/o3s1z9h7/build-on-poster:latest
Give your task definintion a name
Leave the rest of the pages configuration as default, scroll to the bottom and click Next
.
Under Environment variables
click Add environment variable
button.
For Variable Name use
IMAGE_API
and TEXT_API
Since we are utilizing code from someone else’s public container image, it is essential that our variable names align with those used in the code. Let’s create two variables: one to call our stable diffusion lambda function and the other for Text Summarization lambda function.
Leave the remaining configurations as default, scroll to the bottom and click Next
.
Go to the IAM service page or scroll to Task roles
above Task role
click the link to the IAM console to navigate to the page (to grants permission to containers enabling them interact with other AWS services).
Select create role on the IAM page
Leave the defaults select elastic container registry for service below. Then scroll down click next
Under services select Elastic container registry
In the Add permissions
page search for and select AmazonECSTaskExecutionRolePolicy
Clear filter after selecting AmazonECSTaskExecutionRolePolicy.
Search for lambd_fullAccess and select it. To grant ECS containers unrestricted access to our lambda functions.
Click Next
Give your role any name
Scroll to the bottom click create role
.
After successful Role creation we move back to ECS Task definition and select our newly created role under Task role
.
You can turn off cloudwatch log collection
under Logging
to save cost.
Click Next
below to proceed
Click create
below
Running A Task with Our Task Definition
On the left menu click cluster
Click the cluster you created earlier on the cluster page
Click Tasks
tab as shown above, then click the Run new task
button
On the create task page.
Under Compute configuration
, select Launch type
as your compute option to keep things simple.
Under Deployments select the task definition we just created using the drop down as shown below.
Under Networks
We could either edit our default security group to allow inbound traffic or create a new one which does. We would create a new one.
Select create a new security group
under security group
Give your security group a name
Give your security group any description.
For inbound rules under Type
select HTTP
For Source
select "Anywhere"
Also ensure the Public IP
button is toggle On, so we know our IP address and connect to it.
Leave Task overrides
as default
Edit container overrides
We copy the output url of the lambda functions we created in the previous post to summarize text and the function to convert text to image as values of our container environment variables.
Copy the Function url of both functions and paste them into container IMAGE_API and TEXT_API values.
One at a time
Use function url of diffusion function as value of IMAGE_API
and the function url of text_summary function as value of TEXT_API
.
Click save
button to run task. After pasting function url your enviroment variables should like the image below.
Test your site
Under Tasks
click your task
when it gets to the Running
state
Scroll down on the task page
Under Configuration setting
Click the public url
It displays loads our site on a new page
Lets test it
paste or write an article to be summarized and converted to text
You can use an article here
Top comments (0)