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.

Häufig gestellte Fragen

Wie kann ich AWS für die Dokumentensicherheit einrichten?

Um AWS für die Dokumentensicherheit einzurichten, können Sie Container-Instances über Amazon ECS bereitstellen. Dies beinhaltet die Erstellung eines Virtual Private Cloud (VPC), das Einrichten einer Sicherheitsgruppe und die Nutzung von AWS Fargate für serverlose Infrastruktur. IronSecureDoc kann integriert werden, um eine sichere Dokumentenverwaltung zu gewährleisten.

Was ist der Zweck der Erstellung eines Virtual Private Cloud (VPC) in AWS?

Die Erstellung einer VPC in AWS ermöglicht es Ihnen, AWS-Ressourcen in einem logisch isolierten virtuellen Netzwerk zu starten. Diese Einrichtung bietet Kontrolle über Ihre Netzwerkinfrastruktur und ist entscheidend für die Verwaltung der Dokumentensicherheit durch Dienste wie IronSecureDoc.

Warum ist es wichtig, eine Sicherheitsgruppe für ECS-Bereitstellungen einzurichten?

Das Einrichten einer Sicherheitsgruppe ist entscheidend für die Steuerung der ein- und ausgehenden Verbindungen zu Ihren ECS-Container-Instances. Sie fungiert als virtuelle Firewall, die sicherstellt, dass nur autorisierter Datenverkehr die auf AWS bereitgestellten IronSecureDoc-Dienste erreicht.

Wie stelle ich eine Container-Instanz mit AWS Fargate bereit?

Um eine Container-Instanz mit AWS Fargate bereitzustellen, müssen Sie zunächst einen ECS-Cluster erstellen. Dann definieren Sie eine Task-Definition, die die Anforderungen wie CPU, Arbeitsspeicher und Containereinstellungen spezifiziert. Schließlich erstellen Sie einen Dienst innerhalb des ECS-Clusters, um die Bereitstellung von IronSecureDoc zu verwalten.

Welche Rolle spielt eine Task-Definition in Amazon ECS?

In Amazon ECS dient eine Task-Definition als Anwendungs-Blaupause. Sie beschreibt die Anforderungen zum Ausführen Ihrer Container, wie Starttyp, CPU, Arbeitsspeicher und Containerdefinitionen. Dies ist entscheidend für die Bereitstellung von Anwendungen wie IronSecureDoc.

Wie kann ich Umgebungsvariablen in AWS sicher verwalten?

Sie können Umgebungsvariablen in AWS sicher verwalten, indem Sie sensible Daten wie den IronSecureDoc-Lizenzschlüssel aus verschlüsselten Amazon S3-Buckets abrufen. Dieser Ansatz hilft, sensible Informationen vor unbefugtem Zugriff zu schützen.

Wie kann ich die erfolgreiche Bereitstellung meines ECS-Dienstes überprüfen?

Sie können die Bereitstellung Ihres ECS-Dienstes überprüfen, indem Sie die öffentliche IP-Adresse verwenden, um einen curl-Befehl auszuführen. Zum Beispiel sollte die Ausführung von curl http://:8080/v1/document-services/ping 'pong' zurückgeben, was darauf hinweist, dass der IronSecureDoc-Dienst korrekt ausgeführt wird.

Muss ich für jede Bereitstellung eine neue VPC und eine Sicherheitsgruppe erstellen?

Wenn keine Standard-VPC und Sicherheitsgruppe existieren, müssen Sie diese erstellen, um ordnungsgemäße Netzwerk- und Sicherheitskonfigurationen für Ihre ECS-Bereitstellungen sicherzustellen. Diese Einrichtung ist essentiell für das sichere Funktionieren von Anwendungen wie IronSecureDoc.

Curtis Chau
Technischer Autor

Curtis Chau hat einen Bachelor-Abschluss in Informatik von der Carleton University und ist spezialisiert auf Frontend-Entwicklung mit Expertise in Node.js, TypeScript, JavaScript und React. Leidenschaftlich widmet er sich der Erstellung intuitiver und ästhetisch ansprechender Benutzerschnittstellen und arbeitet gerne mit modernen Frameworks sowie der Erstellung gut strukturierter, optisch ansprechender ...

Weiterlesen
Bereit anzufangen?
Version: 2024.10 gerade veröffentlicht