Deploy a container instance in AWS

This article was translated from English: Does it need improvement?
Translated
View the article in English

Amazon Elastic Container Service (Amazon ECS) is a highly scalable, fast, container management service that makes it easy to run, stop, and manage your containers. You can host your containers on a serverless infrastructure that is managed by Amazon ECS by launching your services or tasks on AWS Fargate. For more information on Fargate, see AWS Fargate for Amazon ECS.

Step 1: Sign in to AWS account

Sign in to the AWS portal.

If you do not have an AWS account, then register for a new AWS account.

Step 2: Create a virtual private cloud

You can use Amazon Virtual Private Cloud (Amazon VPC) to launch AWS resources into a virtual network that you've defined. We strongly suggest that you launch your container instances in a VPC.

If you have a default VPC, you can skip this section and move to the next task, Create a security group. To determine whether you have a default VPC, see Supported Platforms in the Amazon EC2 Console in the Amazon EC2 User Guide. Otherwise, you can create a nondefault VPC in your account using the steps below.

For information about how to create a VPC, see Create a VPC only in the Amazon VPC User Guide, and use the following table to determine what options to select.

Option Value
Resources to create VPC only
Name Optionally provide a name for your VPC
IPv4 CIDR block IPv4 CIDR manual input
The CIDR block size must have a size between /16 and /28
IPv6 CIDR block No IPv6 CIDR block
Tenancy Default

For more information about Amazon VPC, see What is Amazon VPC? in the Amazon VPC User Guide.

Step 3: Create a security group

Security groups act as a firewall for associated container instances, controlling both inbound and outbound traffic at the container instance level. You can add rules to a security group that enable you to connect to your container instance from your IP address using SSH. You can also add rules that allow inbound and outbound HTTP and HTTPS access from anywhere. Add any rules to open ports that are required by your tasks. Container instances require external network access to communicate with the Amazon ECS service endpoint.

For information about how to create a security group, see Create a security group in the Amazon EC2 User Guide and use the following table to determine what options to select.

Option Value
Region The same Region in which you created your key pair
Name A name that is easy for you to remember, such as ecs-instances-default-cluster
VPC The default VPC (marked with "(default)"
Note
If your account supports Amazon EC2 Classic, select the VPC that you created in the previous task

Step 4: Create a ECS Cluster

On the AWS portal homepage, search "ECS" in the search box and select "Elastic Container Service". Or open the console at https://console.aws.amazon.com/ecs/v2.

Search ECS

Select "Create cluster".

Create cluster

Enter the "Cluster name". Select only "AWS Fargate (serverless)" in Infrastructure section.

Create cluster values

Leave the other values as their defaults, then select Create.

Step 5: Create a Task Definition

After the cluster is created, select Task Definitions.

Create task definition

Select "Create new task definition", then select "Create new task definition".

Create new task definition

On the Task definition configuration section, enter the value for Task definition family.

Task definition configuration section

On the Infrastructure requirements section, enter the following values for Launch type, CPU, Memory, Task role, and Task execution role.

  • Launch type: Only AWS Fargate
  • CPU: 1 vCPU
  • Memory: 2 GB
  • Task role: ecsTaskExecutionRole
  • Task execution role: ecsTaskExecutionRole

Infrastructure requirements

On the Container - 1 section, enter the following values for Name, Image URI, Container port, Port name, and Environment variables.

  • Name: mycontainer
  • Image URI: Use ironsoftwareofficial/ironsecuredoc for the latest or specify by tag ironsoftwareofficial/ironsecuredoc:2024.7.1
  • Container port: 8080
  • Port name: 8080
  • Add Environment variables:
    • ENVIRONMENT: Production
    • HTTP_PORTS: 8080
    • IronSecureDoc_LicenseKey: YOUR-LICENSE-KEY

For IronSecureDoc_LicenseKey, it is not recommended to add directly into Environment variables for security. It is recommended to retrieve the environment file from an encrypted Amazon S3 bucket, see Pass sensitive data to an Amazon ECS container.

Container section

Leave the other values as their defaults, then select Create.

Step 6: Create a Service

Go back to the Clusters page > Select your cluster (IronSecureDoc).

Select your cluster

Select the "Service" tab > then select "Create".

Create service

In the Environment section, enter the following values for Compute options and Launch type.

  • Compute options: Select Launch type
  • Launch type: Select FARGATE

Service environment

In the Deployment configuration section, enter the following values for Application type, Family, Revision, Service name, and Desired tasks.

  • Application type: Select Service
  • Task definition:
    • Family: Select the created task definition ironsecuredoc
    • Revision: Select task definition revision 1 (LATEST)
  • Service name: myservice
  • Desired tasks: 1

Service deployment configuration

Please note that for networking you may need to create a VPC and a Security group if they do not exist.

Leave the other values as their defaults, then select Create.

When the deployment starts, a notification appears that indicates the deployment is in progress. Another notification is displayed when the service has been deployed.

View your service > then open the task.

Open created task

In Task Configuration, you can use the Public IP to run a curl command to check if the API is working correctly, which should return pong.

curl http://18.118.166.206:8080/v1/document-services/ping
curl http://18.118.166.206:8080/v1/document-services/ping
SHELL

Public IP

Congratulations! By configuring just a few settings, you've deployed a publicly accessible application in Amazon Elastic Container Service.

Questions Fréquemment Posées

Comment puis-je configurer AWS pour la sécurité des documents ?

Pour configurer AWS pour la sécurité des documents, vous pouvez déployer des instances de conteneurs via Amazon ECS. Cela implique de créer un nuage privé virtuel (VPC), de configurer un groupe de sécurité et d'utiliser AWS Fargate pour une infrastructure sans serveur. IronSecureDoc peut être intégré pour assurer une gestion sécurisée des documents.

Quel est le but de créer un nuage privé virtuel (VPC) dans AWS ?

La création d'un VPC dans AWS vous permet de lancer des ressources AWS dans un réseau virtuel isolé logiquement. Cette configuration offre un contrôle sur votre environnement réseau et est cruciale pour gérer la sécurité des documents via des services comme IronSecureDoc.

Pourquoi est-il important de configurer un groupe de sécurité pour les déploiements ECS ?

La configuration d'un groupe de sécurité est essentielle pour contrôler le trafic entrant et sortant vers vos instances ECS. Il agit comme un pare-feu virtuel, garantissant que seul le trafic autorisé atteint les services IronSecureDoc déployés sur AWS.

Comment puis-je déployer une instance de conteneur en utilisant AWS Fargate ?

Pour déployer une instance de conteneur en utilisant AWS Fargate, vous devez d'abord créer un cluster ECS. Ensuite, définissez une définition de tâche spécifiant les exigences comme le CPU, la mémoire et les paramètres du conteneur. Enfin, créez un service au sein du Cluster ECS pour gérer le déploiement d'IronSecureDoc.

Quel rôle joue une Définition de Tâche dans Amazon ECS ?

Dans Amazon ECS, une définition de tâche sert de plan d'application. Elle définit les exigences pour exécuter vos conteneurs, telles que le type de lancement, le CPU, la mémoire et les définitions de conteneur. Cela est crucial pour déployer des applications comme IronSecureDoc.

Comment puis-je gérer les variables d'environnement de manière sécurisée dans AWS ?

Vous pouvez gérer les variables d'environnement de manière sécurisée dans AWS en récupérant les données sensibles, telles que la clé de licence IronSecureDoc, à partir de seaux Amazon S3 cryptés. Cette approche aide à protéger les informations sensibles contre les accès non autorisés.

Comment puis-je vérifier le déploiement réussi de mon service ECS ?

Vous pouvez vérifier le déploiement de votre service ECS en utilisant l'IP publique pour exécuter une commande curl. Par exemple, exécuter curl http://:8080/v1/document-services/ping devrait retourner 'pong', indiquant que le service IronSecureDoc fonctionne correctement.

Dois-je créer un nouveau VPC et un groupe de sécurité pour chaque déploiement ?

Si un VPC et un groupe de sécurité par défaut n'existent pas, vous devez les créer pour assurer des configurations réseau et de sécurité appropriées pour vos déploiements ECS. Cette configuration est essentielle pour le fonctionnement sécurisé des applications comme IronSecureDoc.

Curtis Chau
Rédacteur technique

Curtis Chau détient un baccalauréat en informatique (Université de Carleton) et se spécialise dans le développement front-end avec expertise en Node.js, TypeScript, JavaScript et React. Passionné par la création d'interfaces utilisateur intuitives et esthétiquement plaisantes, Curtis aime travailler avec des frameworks modernes ...

Lire la suite
Prêt à commencer?
Version : 2024.10 vient de sortir