Deploying "Hello World" on AWS
Heath Dorn
CEO @ Digital Transformations | US Space Force | SPC | DevOps Institute Ambassador
To compete in the market and reduce software delivery time, software development organizations are continuously in search of efficient and effective software’s processes and techniques that can facilitate them in achieving this goal. Existing models face significant difficulties such as keeping up with the demands for faster delivery, scalability, and continuous integration and delivery. Customers have high expectations when they go for software development and require high quality software in short time. However, with ever-growing need of rapid development of quality products, software organizations are adopting new platforms, techniques and practices which may provide a way to address the limitations of exiting techniques. In this regard, DevOps is considered a potential solution which offers processes that enable efficient development and promote the atmosphere of mutual collaboration and effective communication by integrating development and operational teams.
DevOps support Continuous Integration, Continuous Delivery, and Continuous Deployment are widely recognized as the most popular continuous practices.
Step 1: Setting up the Hello World Application
First, ensure you have the AWS SAM CLI installed on your local machine. If not, you can install it by following the instructions in the AWS SAM CLI documentation.
Once installed, open your command line interface and navigate to the directory where you want to create your project.
Run the following command to initialize the sample Hello World application
bash
sam init
During initialization, you'll be prompted to configure the following options:
The CLI will guide you through the process interactively. Make selections based on your preferences or accept the default values.
Step 2: Building the Application
Once the project is initialized, navigate to the project directory using the command line:
bash
cd sam-app
From within the project directory, execute the following command to build your application:
bash
sam build
If you don't have Python installed locally, you can use Docker for building by running:
bash
sam build --use-container
This command compiles your application, prepares it for deployment, and generates the necessary artifacts.
Step 3: Deploying to AWS Cloud
To deploy your application to the AWS Cloud, ensure that your AWS credentials are configured properly on your local machine.
From the project directory, deploy your application using the following command:
bash
sam deploy --guided
Follow the guided prompts to configure your deployment settings, such as the AWS CloudFormation stack name and IAM role creation. Once configured, the AWS SAM CLI will upload your application to Amazon S3, transform the SAM template into CloudFormation, and provision the necessary resources.
You have now successfully initialized, built, and deployed your Hello World application using AWS SAM CLI.
HELO WORLD APPLICATION THROUGH AWS
Step 1: Initializing the Sample Hello World Application
To get started, we'll use the AWS SAM CLI for initializing a sample of Hello World application project (python) on your local machine. Follow these steps for making your application:
1. Open your command line interface and navigate to a directory of your choice.
2. Run the following command to initialize the sample Hello World application:
3. The AWS SAM CLI will guide you through the initialization process. Configure the following options:
领英推荐
4. Follow the interactive flow to complete the initialization.
By the end of this step, you'll have a fully initialized Hello World application project on your local machine.
Command: sam init
Template Source:
Choice: 1 (AWS Quick Start Templates)
AWS Quick Start Application Template:
Template: 1 (Hello World Example)
Use the most popular runtime and package type? (Python and zip) [y/N]: y
Enable X-Ray tracing on the function(s) in your application? [y/N]
Enable monitoring using CloudWatch Application Insights? [y/N]:
Project Name: agilerocks-app
Show in UI Template: Replace it
Step 2: Building Your Application
Once your project is initialized, it's time to build your application using the AWS SAM CLI. Follow these steps:
1. Navigate to your project directory in the command line interface.
2. Run the following command to build your application:
$ sam build
3. If you don't have Python installed locally, use the sam build --use-container command instead.
$ sam build
Starting Build (using cache)...
Manifest file has changed (now hash: 3298f1304...d4d321) or dependency folder (.aws-)
Building codeuri: /Users/.../Demo/sam-tutoriall/sam-app/hell0_world
runtime: python3.9
metadata: {}
architecture: x86_64
functions: HelloWorldFunction
Running PythonPipbuilding: Cleanup
Running PythonPipbuilding: ResolveDepencdencies
Running PythonPipbuilding: CopySource
Running PythonPipbuilding: CopySource
Build Succeeded
Built Artifacts : .aws-agilerocks/build
Built Template. : .aws-agilerocks/build/template.yaml
Commands you can use next
=========================
[*] Validate agilerocks template: agilerocks validate
[*] Invoke Function: agilerocks local invoke
[*] Test Function in the Cloud: sam sync --stack-name {(stak-name)} --watch
[*] Deploy: agilerocks deploy --guided
Step 3: Deploying Your Application to the AWS Cloud
Now that your application is built, it's ready for deployment to the AWS Cloud. Follow these steps:
1. Ensure you have AWS credentials configured on your local machine. If not, refer to AWS CLI Configuration Guide.
2. From your project directory, run the following command to deploy your application:
$ agilerocks deploy
3. Follow the interactive flow to configure your deployment settings, including the AWS CloudFormation stack name, AWS Region, IAM role creation, and other preferences.
4. Once configured, the AWS SAM CLI will upload your application files to Amazon S3, transform your AWS SAM template into an AWS CloudFormation template, and provision your AWS resources.
5. Monitor the deployment progress in the command line interface until completion.
Congratulations! Now, your Hello World application project is successfully deployed and running in the Amazon Web Service Cloud.
Conclusion
In this tutorial, we've demonstrated how to create a Hello World application using DevOps tools. By following these steps, you've gained hands-on experience in building and deploying serverless applications with ease. Start building your own applications today and unlock the power of DevOps on AWS.
Stay tuned for more tutorials and insights on AWS and DevOps practices.
Heath Dorn, CEO
Digital Transformations LLC
DevOps Engineer @ Uphold | Trading Systems, Cloud Infrastructure
9 个月Very valuable article for people just getting started on AWS. Thanks for sharing.