AWS interview questions
37 questions, 35 with answers. 3,991 open jobs in India ask for AWS.
What is AWS?
AWS (Amazon Web Services) is a cloud computing platform provided by Amazon. It offers a wide range of on-demand computing services and resources, such as servers, storage, databases, networking, and more, over the internet. AWS allows businesses and individuals to access and utilize these services without the need to own and manage physical hardware. It's commonly used for hosting websites, running applications, and storing data, offering scalability and flexibility to meet various computing needs.
From Tech Vault (Apache 2.0)
What are two services of AWS where you could store secrets?
Two AWS services for storing secrets securely are:
-
AWS Secrets Manager: A service specifically designed for managing and rotating sensitive information like database passwords, API keys, and other credentials. It provides encryption, automated rotation, and access control for secrets.
-
AWS Parameter Store: A service that allows you to store and manage configuration data, including secrets, in a hierarchical structure. It's often used for storing application configuration parameters and secrets in a secure manner.
From Tech Vault (Apache 2.0)
-
What is the relation between the Availability Zone and Region in AWS?
-
A Region is a geographical area that consists of multiple, isolated Availability Zones. AWS Regions are entirely separate from one another and are spread across the world to provide geographic diversity and redundancy.
-
An Availability Zone (AZ) is a data center or facility within an AWS Region. Each Availability Zone is physically separate from the others and is designed to be isolated from failures in other Availability Zones within the same Region. This isolation ensures high availability and fault tolerance.
In summary, AWS Regions are composed of multiple Availability Zones. When you choose a Region for your resources, you're selecting a specific geographical location with multiple isolated data centers (Availability Zones) to host your services and data. This setup enables redundancy, scalability, and resilience for your applications and infrastructure.
From Tech Vault (Apache 2.0)
-
What is auto-scaling?
- Auto-scaling is a cloud computing feature that automatically adjusts the number of resources (such as servers) allocated to your application based on real-time demand. It helps ensure that your application can handle varying levels of traffic efficiently by adding or removing resources as needed, thereby improving performance and cost-efficiency.
From Tech Vault (Apache 2.0)
What services can help minimise a DDoS attack?
To minimize a Distributed Denial of Service (DDoS) attack on your infrastructure, you can use services like:
- AWS Shield: AWS Shield is a managed DDoS protection service that safeguards your applications against large-scale, sophisticated attacks.
From Tech Vault (Apache 2.0)
What is an AMI?
- An AMI (Amazon Machine Image) is a pre-configured and templated virtual machine image used to create virtual servers (EC2 instances) in Amazon Web Services (AWS). It contains an operating system, software applications, and any custom configurations needed for your cloud-based servers. AMIs enable you to quickly launch and replicate server instances, making it easier to scale your infrastructure and deploy consistent computing environments.
From Tech Vault (Apache 2.0)
What are different types of load balancers?
There are three main types of load balancers:
-
Application Load Balancer (ALB): ALBs operate at the application layer (Layer 7) and are ideal for routing HTTP and HTTPS traffic. They are capable of content-based routing, SSL termination, and support for container-based applications.
-
Network Load Balancer (NLB): NLBs function at the transport layer (Layer 4) and are designed for handling TCP, UDP, and TLS traffic. They are highly performant and suitable for low-latency and high-throughput workloads.
-
Classic Load Balancer (CLB): CLBs are the legacy load balancers in AWS, offering basic Layer 4 and Layer 7 load balancing capabilities. They are typically used for simple traffic distribution requirements.
Each type of load balancer has specific use cases and features, allowing you to choose the one that best suits your application's needs.
From Tech Vault (Apache 2.0)
-
What is a VPC?
A VPC (Virtual Private Cloud) is a virtual network environment provided by Amazon Web Services (AWS). It allows you to create and configure a logically isolated section of the AWS cloud where you can launch AWS resources like virtual servers (EC2 instances), databases, and more.
Key features of a VPC include:
-
Isolation: VPCs provide network isolation, allowing you to create private and public subnets to control access to resources.
-
Custom IP Address Ranges: You can define your IP address range for the VPC, enabling you to design your network architecture.
-
Security Groups and Network ACLs: These allow you to control inbound and outbound traffic to and from resources within the VPC.
-
Connectivity Options: VPCs can be connected to other VPCs, on-premises networks, and the internet using various networking options.
-
Subnets: VPCs are divided into subnets, each associated with a specific Availability Zone. Subnets are used to distribute resources and provide high availability.
In summary, a VPC is a fundamental networking component in AWS that lets you create a virtual network environment to host and manage your cloud-based resources with control over network architecture and security.
From Tech Vault (Apache 2.0)
-
How do Subnets work?
- Subnets are like separate neighborhoods within your cloud network. Each subnet has its own area of IP addresses and is isolated from the others. They're often placed in different parts of the cloud for extra safety, and you can control how traffic flows in and out of each subnet. This helps keep your cloud resources organized and secure.
From Tech Vault (Apache 2.0)
What network object do you need to allow a server ingress from the internet?
- To allow a server to receive incoming traffic from the internet, you typically need to configure a security group (in AWS) or a firewall rule aka NACL (in general networking terms) to permit incoming traffic on the specific ports or protocols you want to allow. This enables your server to accept requests from the internet while still maintaining security by specifying which traffic is allowed.
From Tech Vault (Apache 2.0)
How can your resources in the VPC get access to the internet?
To allow resources in your VPC to access the internet, you need to set up the following:
-
Internet Gateway (IGW): Attach an Internet Gateway to your VPC. It acts as a bridge between your VPC and the internet.
-
Route Table: Modify the route table associated with your subnets to include a route (0.0.0.0/0) pointing to the Internet Gateway.
-
Elastic IP (EIP): For resources like EC2 instances that need a static public IP, allocate and associate an Elastic IP address.
With these configurations, resources in your VPC can send and receive traffic to and from the internet through the Internet Gateway while maintaining network security through security groups and network ACLs.
From Tech Vault (Apache 2.0)
-
I want to create a 3 Tier Architecture. Can you explain step by step of how I can go about this?
- Presentation Layer (Web):
Step 1: Launch an Amazon EC2 instance for your web server. This instance will host your website or web application. Step 2: Configure security groups to allow incoming web traffic (HTTP/HTTPS) to the web server. Step 3: Optionally, attach an Elastic IP (EIP) for a static public IP address.
- Application Layer (App):
Step 4: Launch another EC2 instance for your application server(s). This instance runs the business logic of your application. Step 5: Configure security groups to allow incoming traffic from the web server to the application server on the necessary ports. Step 6: Install and configure any middleware or application software required for your application.
- Data Layer (Database):
Step 7: Create an Amazon RDS (Relational Database Service) instance or set up a database server (e.g., on EC2) for your database layer. Step 8: Configure security groups to allow incoming database connections only from the application server(s). Step 9: Create your database schema and tables, and configure database access and permissions.
From Tech Vault (Apache 2.0)
In VPC with private and public subnets, database servers should ideally be launched into which subnet?
- In a VPC with both private and public subnets, database servers should ideally be launched into the private subnets. Placing database servers in private subnets ensures that they are not directly accessible from the internet, which enhances security. Public subnets are typically used for resources that need to be accessible from the internet, like web servers.
From Tech Vault (Apache 2.0)
What are some security best practices for EC2s?
-
Use Security Groups: Configure security groups to control incoming and outgoing traffic to your EC2 instances. Only allow necessary ports and sources.
-
Use Key Pairs: Authenticate access to your EC2 instances using key pairs (SSH keys for Linux or RDP keys for Windows) instead of passwords.
-
Regular Updates: Keep your EC2 instances and their software up to date with security patches and updates.
-
Use IAM Roles: Assign IAM roles to EC2 instances to grant them specific permissions, reducing the need for storing access keys on the instance.
-
Enable Monitoring: Use Amazon CloudWatch to monitor performance and set up alarms for unusual activity or resource exhaustion.
-
Data Encryption: Encrypt data at rest using services like Amazon EBS encryption and in-transit using SSL/TLS.
-
Snapshot Backups: Create EBS snapshots and AMIs regularly to back up your instances, ensuring data recovery in case of failures.
-
Instance Isolation: Separate instances into public and private subnets within a Virtual Private Cloud (VPC) for network isolation.
-
Disable Root Access: Disable remote root login on Linux instances and use a sudo user for administrative tasks.
IAM Policies: Use fine-grained IAM policies to restrict access based on the principle of least privilege.
-
Use Bastion Hosts: If necessary, employ a bastion host (jump server) to access private instances securely.
-
Monitor Access: Monitor and audit access to your EC2 instances, including login attempts and user actions.
-
Automate Security: Implement automation tools like AWS Systems Manager and AWS Config to enforce security policies.
From Tech Vault (Apache 2.0)
-
I created a web application with autoscaling. I observed that the traffic on my application is the highest on Wednesdays and Fridays between 9 AM and 7 PM. What would be the best solution for me to handle the scaling?
To handle scaling for your web application with high traffic on Wednesdays and Fridays between 9 AM and 7 PM, you can:
-
Schedule-Based Auto Scaling: Use AWS Auto Scaling's scheduled scaling feature. Set up a schedule to increase the desired number of instances during the peak hours on Wednesdays and Fridays and decrease it during off-peak hours.
-
Target Tracking Scaling Policy: Create a target tracking scaling policy based on a metric like CPU utilization or request count per instance. Set the target to automatically adjust the number of instances to maintain a specific metric value. This can help handle traffic fluctuations efficiently.
By combining these approaches, your application can automatically adjust its capacity to meet demand, ensuring it scales up during peak times and scales down during quieter periods, optimizing cost and performance.
From Tech Vault (Apache 2.0)
-
You have an application running on your Amazon EC2 instance. You want to reduce the load on your instance as soon as the CPU utilization reaches 100 percent. How will you do that?
To automatically reduce the load on your Amazon EC2 instance when CPU utilization reaches 100 percent, follow these steps:
-
Create an Auto Scaling Group: Set up an Auto Scaling Group for your EC2 instance if you haven't already.
-
Create a Target Tracking Scaling Policy: Within the Auto Scaling Group configuration, create a Target Tracking Scaling Policy.
-
Select CPU Utilization as the Metric: Choose CPU utilization as the metric to track.
-
Set the Target Value: Specify the target CPU utilization level at which you want to take action, such as 80 or 90 percent, not 100 percent, to avoid any performance issues. AWS Auto Scaling will automatically adjust the number of instances to maintain this target value.
-
Define Scaling Actions: Configure scaling actions for when the CPU utilization exceeds the target value. You can specify actions to increase or decrease the number of instances based on your requirements.
-
Apply the Policy: Apply the Target Tracking Scaling Policy to your Auto Scaling Group.
From Tech Vault (Apache 2.0)
-
What is the difference between Amazon SNS and Amazon SQS?
SNS is a distributed publish-subscribe system. Messages are pushed to subscribers as and when they are sent by publishers to SNS.
SQS is distributed queuing system. Messages are not pushed to receivers. Receivers have to poll or pull messages from SQS. Messages can't be received by multiple receivers at the same time. Any one receiver can receive a message, process and delete it. Other receivers do not receive the same message later. Polling inherently introduces some latency in message delivery in SQS unlike SNS where messages are immediately pushed to subscribers. SNS supports several end points such as email, SMS, HTTP end point and SQS. If you want unknown number and type of subscribers to receive messages, you need SNS.
You don't have to couple SNS and SQS always. You can have SNS send messages to email, SMS or HTTP end point apart from SQS. There are advantages to coupling SNS with SQS. You may not want an external service to make connections to your hosts (a firewall may block all incoming connections to your host from outside).
Your end point may just die because of heavy volume of messages. Email and SMS maybe not your choice of processing messages quickly. By coupling SNS with SQS, you can receive messages at your pace. It allows clients to be offline, tolerant to network and host failures. You also achieve guaranteed delivery. If you configure SNS to send messages to an HTTP end point or email or SMS, several failures to send message may result in messages being dropped.
SQS is mainly used to decouple applications or integrate applications. Messages can be stored in SQS for a short duration of time (maximum 14 days). SNS distributes several copies of messages to several subscribers. For example, let’s say you want to replicate data generated by an application to several storage systems. You could use SNS and send this data to multiple subscribers, each replicating the messages it receives to different storage systems (S3, hard disk on your host, database, etc.).
From Stack Overflow: asked by Nick Ginanto, answered by Srikanth (CC BY-SA 4.0)
Is there a way to list all resources in AWS
Yes. Use the Tag Editor.
Set "Regions" to "All Regions", "Resource Types" to "All supported resource types" and then click on "Search Resources".
From Stack Overflow: asked by Lakin Lu, answered by schmmd (CC BY-SA 4.0)
What is difference between Lightsail and EC2?
Testing¹ reveals that Lightsail instances in fact are EC2 instances, from the
t2class of burstable instances.EC2, of course, has many more instance families and classes other than the t2, almost all of which are more "powerful" (or better equipped for certain tasks) than these, but also much more expensive. But for meaningful comparisons, the 512 MiB Lightsail instance appears to be completely equivalent in specifications to the similarly-priced t2.nano, the 1GiB is a t2.micro, the 2 GiB is a t2.small, etc.
Lightsail is a lightweight, simplified product offering -- hard disks are fixed size EBS SSD volumes, instances are still billable when stopped, security group rules are much less flexible, and only a very limited subset of EC2 features and options are accessible.
It also has a dramatically simplified console, and even though the machines run in EC2, you can't see them in the EC2 section of the AWS console. The instances run in a special VPC, but this aspect is also provisioned automatically, and invisible in the console. Lightsail supports optionally peering this hidden VPC with your default VPC in the same AWS region, allowing Lightsail instances to access services like EC2 and RDS in the default VPC within the same AWS account.²
Bandwidth is unlimited, but of course free bandwidth is not -- however, Lightsail instances do include a significant monthly bandwidth allowance before any bandwidth-related charges apply.³ Lightsail also has a simplified interface to Route 53 with limited functionality.
But if those sound like drawbacks, they aren't. The point of Lightsail seems to be simplicity. The flexibility of EC2 (and much of AWS) leads inevitably to complexity. The target market for Lightsail appears to be those who "just want a simple VPS" without having to navigate the myriad options available in AWS services like EC2, EBS, VPC, and Route 53. There is virtually no learning curve, here. You don't even technically need to know how to use SSH with a private key -- the Lightsail console even has a built-in SSH client -- but there is no requirement that you use it. You can access these instances normally, with a standard SSH client.
¹Lightsail instances, just like "regular" EC2 (VPC and Classic) instances, have access to the instance metadata service, which allows an instance to discover things about itself, such as its instance type and availability zone. Lightsail instances are identified in the instance metadata as
t2machines.²The Lightsail docs are not explicit about the fact that peering only works with your Default VPC, but this appears to be the case. If your AWS account was created in 2013 or before, then you may not actually have a VPC with the "Default VPC" designation. This can be resolved by submitting a support request, as I explained in Can't establish VPC peering connection from Amazon Lightsail (at Server Fault).
³The bandwidth allowance applies to both inbound and outbound traffic; after this total amount of traffic is exceeded, inbound traffic continues to be free, but outbound traffic becomes billable. See "What does data transfer cost?" in the Lightsail FAQ.
From Stack Overflow: asked by mohitmun, answered by Michael - sqlbot (CC BY-SA 4.0)
Can an AWS Lambda function call another
I found a way using the
aws-sdk.var aws = require('aws-sdk'); var lambda = new aws.Lambda({ region: 'us-west-2' //change to your region }); lambda.invoke({ FunctionName: 'name_of_your_lambda_function', Payload: JSON.stringify(event, null, 2) // pass params }, function(error, data) { if (error) { context.done('error', error); } if (data.Payload) { context.succeed(data.Payload); } });You can find the doc here: http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Lambda.html
From Stack Overflow: asked by Silver, answered by picsoung (CC BY-SA 4.0)
AWS EFS vs EBS vs S3 (differences & when to use?)
One word answer: MONEY :D
1 GB to store in US-East-1: (Updated at 2016.dec.20)
- Glacier: $0.004/Month (Note: Major price cut in 2016)
- S3: $0.023/Month
- S3-IA (announced in 2015.09): $0.0125/Month (+$0.01/gig retrieval charge)
- EBS: $0.045-0.1/Month (depends on speed - SSD or not) + IOPS costs
- EFS: $0.3/Month
Further storage options, which may be used for temporary storing data while/before processing it:
- SNS
- SQS
- Kinesis stream
- DynamoDB, SimpleDB
The costs above are just samples. There can be differences by region, and it can change at any point. Also there are extra costs for data transfer (out to the internet). However they show a ratio between the prices of the services.
There are a lot more differences between these services:
EFS is:
- Generally Available (out of preview), but may not yet be available in your region
- Network filesystem (that means it may have bigger latency but it can be shared across several instances; even between regions)
- It is expensive compared to EBS (~10x more) but it gives extra features.
- It's a highly available service.
- It's a managed service
- You can attach the EFS storage to an EC2 Instance
- Can be accessed by multiple EC2 instances simultaneously
- Since 2016.dec.20 it's possible to attach your EFS storage directly to on-premise servers via Direct Connect. ()
EBS is:
- A block storage (so you need to format it). This means you are able to choose which type of file system you want.
- As it's a block storage, you can use Raid 1 (or 0 or 10) with multiple block storages
- It is really fast
- It is relatively cheap
- With the new announcements from Amazon, you can store up to 16TB data per storage on SSD-s.
- You can snapshot an EBS (while it's still running) for backup reasons
- But it only exists in a particular region. Although you can migrate it to another region, you cannot just access it across regions (only if you share it via the EC2; but that means you have a file server)
- You need an EC2 instance to attach it to
- New feature (2017.Feb.15): You can now increase volume size, adjust performance, or change the volume type while the volume is in use. You can continue to use your application while the change takes effect.
S3 is:
- An object store (not a file system).
- You can store files and "folders" but can't have locks, permissions etc like you would with a traditional file system
- This means, by default you can't just mount S3 and use it as your webserver
- But it's perfect for storing your images and videos for your website
- Great for short term archiving (e.g. a few weeks). It's good for long term archiving too, but Glacier is more cost efficient.
- Great for storing logs
- You can access the data from every region (extra costs may apply)
- Highly Available, Redundant. Basically data loss is not possible (99.999999999% durability, 99.9 uptime SLA)
- Much cheaper than EBS.
- You can serve the content directly to the internet, you can even have a full (static) website working direct from S3, without an EC2 instance
Glacier is:
- Long term archive storage
- Extremely cheap to store
- Potentially very expensive to retrieve
- Takes up to 4 hours to "read back" your data (so only store items you know you won't need to retrieve for a long time)
Read the rest at the sourceFrom Stack Overflow: asked by Integralist, answered by Adam Ocsvari (CC BY-SA 3.0)
Difference between Amazon EC2 and AWS Elastic Beanstalk
First off, EC2 and Elastic Compute Cloud are the same thing.
Next, AWS encompasses the range of Web Services that includes EC2 and Elastic Beanstalk. It also includes many others such as S3, RDS, DynamoDB, and all the others.
EC2
EC2 is Amazon's service that allows you to create a server (AWS calls these instances) in the AWS cloud. You pay by the hour and only what you use. You can do whatever you want with this instance as well as launch
nnumber of instances.Elastic Beanstalk
Elastic Beanstalk is one layer of abstraction away from the EC2 layer. Elastic Beanstalk will setup an "environment" for you that can contain a number of EC2 instances, an optional database, as well as a few other AWS components such as a Elastic Load Balancer, Auto-Scaling Group, Security Group. Then Elastic Beanstalk will manage these items for you whenever you want to update your software running in AWS. Elastic Beanstalk doesn't add any cost on top of these resources that it creates for you. If you have 10 hours of EC2 usage, then all you pay is 10 compute hours.
Running Wordpress
For running Wordpress, it is whatever you are most comfortable with. You could run it straight on a single EC2 instance, you could use a solution from the AWS Marketplace, or you could use Elastic Beanstalk.
What to pick?
In the case that you want to reduce system operations and just focus on the website, then Elastic Beanstalk would be the best choice for that. Elastic Beanstalk supports a PHP stack (as well as others). You can keep your site in version control and easily deploy to your environment whenever you make changes. It will also setup an Autoscaling group which can spawn up more EC2 instances if traffic is growing.
Here's the first result off of Google when searching for "elastic beanstalk wordpress": https://www.otreva.com/blog/deploying-wordpress-amazon-web-services-aws-ec2-rds-via-elasticbeanstalk/
From Stack Overflow: asked by Ahmad Ismail, answered by Josh Davis (CC BY-SA 3.0)
Benefits of EBS vs. instance-store (and vice-versa)
The bottom line is you should almost always use EBS backed instances.
Here's why
- EBS backed instances can be set so that they cannot be (accidentally) terminated through the API.
- EBS backed instances can be stopped when you're not using them and resumed when you need them again (like pausing a Virtual PC), at least with my usage patterns saving much more money than I spend on a few dozen GB of EBS storage.
- EBS backed instances don't lose their instance storage when they crash (not a requirement for all users, but makes recovery much faster)
- You can dynamically resize EBS instance storage.
- You can transfer the EBS instance storage to a brand new instance (useful if the hardware at Amazon you were running on gets flaky or dies, which does happen from time to time)
- It is faster to launch an EBS backed instance because the image does not have to be fetched from S3.
- If the hardware your EBS-backed instance is scheduled for maintenance, stopping and starting the instance automatically migrates to new hardware. I was also able to move an EBS-backed instance on failed hardware by force-stopping the instance and launching it again (your mileage may vary on failed hardware).
I'm a heavy user of Amazon and switched all of my instances to EBS backed storage as soon as the technology came out of beta. I've been very happy with the result.
EBS can still fail - not a silver bullet
Keep in mind that any piece of cloud-based infrastructure can fail at any time. Plan your infrastructure accordingly. While EBS-backed instances provide certain level of durability compared to ephemeral storage instances, they can and do fail. Have an AMI from which you can launch new instances as needed in any availability zone, back up your important data (e.g. databases), and if your budget allows it, run multiple instances of servers for load balancing and redundancy (ideally in multiple availability zones).
When Not To
At some points in time, it may be cheaper to achieve faster IO on Instance Store instances. There was a time when it was certainly true. Now there are many options for EBS storage, catering to many needs. The options and their pricing evolve constantly as technology changes. If you have a significant amount of instances that are truly disposable (they don't affect your business much if they just go away), do the math on cost vs. performance. EBS-backed instances can also die at any point in time, but my practical experience is that EBS is more durable.
From Stack Overflow: asked by HelloWorldy, answered by Eric J. (CC BY-SA 3.0)
What does the "EC2-Other" filter in the AWS Cost Explorer dashboard mean?
There are 2 parts to your question (give a man a fish, and teach him how to fish).
- Costs for EC2-Other include things such EBS, Data transfer, Load Balancers, etc.
- If you'd really want to check internally what you're being charged for, go to "Cost Explorer", select the monthly cost report, filter on the right the "EC2-Other" service, and group by "Usage Type"
Good luck
From Stack Overflow: asked by Ammar Badran, answered by Dvir669 (CC BY-SA 4.0)
When to use Amazon Cloudfront or S3?
Amazon S3 is designed for large-capacity, low-cost file storage in one specific geographical region.* The storage and bandwidth costs are quite low.
Amazon CloudFront is a Content Delivery Network (CDN) which proxies and caches web data at edge locations as close to users as possible.
When end users request an object using this domain name, they are automatically routed to the nearest edge location for high performance delivery of your content. (Amazon)
The data served by CloudFront may or may not come from S3. Since it is more optimized for delivery speed, the bandwidth costs a little more.
If your user base is localized, you won't see too much difference working with S3 or CloudFront (but you have to choose the right location for your S3 bucket: US, EU, APAC). If your user base is spread globally and speed is important, CloudFront may be a better option.
Both S3 and CloudFront allow domain aliases, however CloudFront allows multiple aliases so that
d1.mystatics.com,d2.mystatics.comandd3.mystatics.comcould all point to the same location increasing the capacity for parallel downloads (this used to be recommended by Google but with the introduction of SPDY and HTTP/2 is of lesser importance).CloudFront also supports CORS as of 2014 (thanks sergiopantoja).
* Note: S3 can now automatically replicate to additional regions as of 2015.
From Stack Overflow: asked by Kamo, answered by eillarra (CC BY-SA 3.0)
What data is stored in Ephemeral Storage of Amazon EC2 instance?
Anything that is not stored on an EBS volume that is mounted to the instance will be lost.
For example, if you mount your EBS volume at
/mystuff, then anything not in/mystuffwill be lost. If you don't mount an ebs volume and save stuff on it, then I believe everything will be lost.You can create an AMI from your current machine state, which will contain everything in your ephemeral storage. Then, when you launch a new instance based on that AMI it will contain everything as it is now.
Update: to clarify based on comments by mattgmg1990 and glenn bech:
Note that there is a difference between "stop" and "terminate". If you "stop" an instance that is backed by EBS then the information on the root volume will still be in the same state when you "start" the machine again. According to the documentation, "By default, the root device volume and the other Amazon EBS volumes attached when you launch an Amazon EBS-backed instance are automatically deleted when the instance terminates" but you can modify that via configuration.
From Stack Overflow: asked by Gaurav Agarwal, answered by digitaljoel (CC BY-SA 4.0)
What is the best way to pass AWS credentials to a Docker container?
The best way is to use IAM Role and do not deal with credentials at all. (see http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html )
Credentials could be retrieved from
http://169.254.169.254.....Since this is a private ip address, it could be accessible only from EC2 instances.All modern AWS client libraries "know" how to fetch, refresh and use credentials from there. So in most cases you don't even need to know about it. Just run ec2 with correct IAM role and you good to go.
As an option you can pass them at the runtime as environment variables ( i.e
docker run -e AWS_ACCESS_KEY_ID=xyz -e AWS_SECRET_ACCESS_KEY=aaa myimage)You can access these environment variables by running printenv at the terminal.
From Stack Overflow: asked by suraj chopade, answered by Vor (CC BY-SA 4.0)
Do you get charged for a 'stopped' instance on EC2?
No.
You get charged for:
- Online time
- Storage space (assumably you store the image on S3 [EBS])
- Elastic IP addresses
- Bandwidth
So... if you stop the EC2 instance you will only have to pay for the storage of the image on S3 (assuming you store an image ofcourse) and any IP addresses you've reserved.
From Stack Overflow: asked by Mantorok, answered by Wolph (CC BY-SA 3.0)
What is the difference between a task and a service in AWS ECS?
A Task Definition is a collection of 1 or more container configurations. Some Tasks may need only one container, while other Tasks may need 2 or more potentially linked containers running concurrently. The Task definition allows you to specify which Docker image to use, which ports to expose, how much CPU and memory to allot, how to collect logs, and define environment variables.
A Task is created when you run a Task directly, which launches container(s) (defined in the task definition) until they are stopped or exit on their own, at which point they are not replaced automatically. Running Tasks directly is ideal for short-running jobs, perhaps as an example of things that were accomplished via
cron.A Service is used to guarantee that you always have some number of Tasks running at all times. If a Task's container exits due to an error, or the underlying EC2 instance fails and is replaced, the ECS Service will replace the failed Task. This is why we create Clusters so that the Service has plenty of resources in terms of CPU, Memory and Network ports to use. To us it doesn't really matter which instance Tasks run on so long as they run. A Service configuration references a Task definition. A Service is responsible for creating Tasks.
Services are typically used for long-running applications like web servers. For example, if I deployed my website powered by Node.JS in Oregon (us-west-2) I would want say at least three Tasks running across the three Availability Zones (AZ) for the sake of High-Availability; if one fails I have another two and the failed one will be replaced (read that as self-healing!). Creating a Service is the way to do this. If I had 6 EC2 instances in my cluster, 2 per AZ, the Service will automatically balance Tasks across zones as best it can while also considering CPU, memory, and network resources.
UPDATE:
I'm not sure it helps to think of these things hierarchically.
Another very important point is that a Service can be configured to use a load balancer, so that as it creates the Tasks—that is it launches containers defined in the Task Definition—the Service will automatically register the container's EC2 instance with the load balancer. Tasks cannot be configured to use a load balancer, only Services can.
From Stack Overflow: asked by Bob Jones, answered by talentedmrjones (CC BY-SA 4.0)
What is the difference between Amazon ECS and Amazon EC2?
Your question
Is ECS just a docker install in EC2? If I already have a EC2, then I start a ECS, does it mean I have two instance?
No.
AWS ECSis just a logical grouping (cluster) ofEC2instances, and all theEC2instances part of anECSact asDockerhost i.e. ECS can send command to launch a container on them (EC2). If you already have an EC2, and then launch ECS, you'll still have a single instance. If you add/register (by installing the AWS ECS Container Agent) the EC2 to ECS it'll become the part of the cluster, but still a single instance of EC2.An Amazon ECS without any EC2 registered (added to the cluster) is good for nothing.
TL; DR
An overview
EC2- is simply a remote (virtual) machine.ECSstands forElastic Container Service- as per basic definition of computer cluster,ECSis basically a logical grouping ofEC2machines/instances. Technically speakingECSis a mere configuration for an efficient use and management of yourEC2instance(s) resources i.e. storage, memory, CPU, etc.
To simplify it further, if you have launched an
Amazon ECSwith noEC2instances added to it, it's good for nothing i.e. you can't do anything about it.ECSmakes sense only once one (or more)EC2instances are added to it.The next confusing thing here is the container term - which is not fully virtualized machine instances, and Docker is one technology we can use to create container instances.
Dockeris a utility you can install on our machine, which makes it aDockerhost, and on this host you can create containers (same as virtual machines - but much more light-weight). To sum up,ECSis just about clustering of EC2 instances, and usesDockerto instantiate containers/instances/virtual machines on these (EC2) hosts.All you need to do is launch an
ECS, and register/add as muchEC2instances to it as you need. You can add/register EC2 instances, all you need is Amazon ECS Container Agent running on your EC2 instance/machine, which can be done manually or directly using the special AMI (Amazon Machine Image) i.e. Amazon ECS-optimized AMI, which already has the Amazon ECS Container Agent. During the launch of a new EC2 instance the Agent automatically registers it to the default ECS cluster.The container agent running on each of the instances (
EC2instances) within anAmazon ECScluster sends information about the instance's current running tasks and resource utilization to Amazon ECS, and starts and stops tasks whenever it receives a request from Amazon ECS. For more information, see Amazon ECS Container Agent. Once set, each of the created container instances (of whateverEC2machine/node) will be an instance inAmazon ECS's swarm.For more information – read step 10 from this documentation: Launching an Amazon ECS Container Instance:
Read the rest at the sourceFrom Stack Overflow: asked by paynestrike, answered by Nabeel Ahmed (CC BY-SA 3.0)
After the last page: 2 questions more, without answers. Go to the last page
Related topics
Where these questions come from
Open-source collections on GitHub, official documentation, a government careers service and the Stack Exchange sites, each used under its own licence. The answers are the authors' own words: we only tidy the layout, leave out pictures, and cut a long answer with a link to the rest. Stack Exchange answers stay under CC BY-SA and name who asked and who answered.
- Tech Vaultby moabukar and contributorsApache 2.017 questions
- Linux Sysadmin Interview Questionsby chassing and contributorsPublic domain (Unlicense)1 question
- Stack Overflowby its contributors, named on each answerCC BY-SA19 questions