<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	
	xmlns:georss="http://www.georss.org/georss"
	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
	>

<channel>
	<title>Cloud Computing &#8211; Cloud Nine Apps</title>
	<atom:link href="https://cloudnineapps.com/blogs/cloud-computing/feed/" rel="self" type="application/rss+xml" />
	<link>https://cloudnineapps.com</link>
	<description>Simplifying Technology</description>
	<lastBuildDate>Sat, 11 Feb 2023 22:22:34 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.4.16</generator>

<image>
	<url>https://i2.wp.com/cloudnineapps.com/wp-content/uploads/cropped-CloudNineApps_favicon-2.png?fit=32%2C32&#038;ssl=1</url>
	<title>Cloud Computing &#8211; Cloud Nine Apps</title>
	<link>https://cloudnineapps.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">136749396</site>	<item>
		<title>How To Use AWS CloudWatch With On-Premise Application Components?</title>
		<link>https://cloudnineapps.com/blogs/cloud-computing/how-to-use-aws-cloudwatch-with-on-premise-application-components/</link>
					<comments>https://cloudnineapps.com/blogs/cloud-computing/how-to-use-aws-cloudwatch-with-on-premise-application-components/#respond</comments>
		
		<dc:creator><![CDATA[Nitin Patil]]></dc:creator>
		<pubDate>Thu, 09 Jan 2020 11:27:36 +0000</pubDate>
				<category><![CDATA[Cloud Computing]]></category>
		<guid isPermaLink="false">https://cloudnineapps.com/?p=4424</guid>

					<description><![CDATA[<p>How To Use AWS CloudWatch With On-Premise Application Components? AWS CloudWatch offers centralized logging, monitoring, and analysis to make the developer&#8217;s job easier. A question that comes up for the Enterprise Applications that follow a hybrid cloud deployment (that is,&#8230;&#160;<a href="https://cloudnineapps.com/blogs/cloud-computing/how-to-use-aws-cloudwatch-with-on-premise-application-components/" class="more-link">Read More</a></p>
<p>The post <a rel="nofollow" href="https://cloudnineapps.com/blogs/cloud-computing/how-to-use-aws-cloudwatch-with-on-premise-application-components/">How To Use AWS CloudWatch With On-Premise Application Components?</a> appeared first on <a rel="nofollow" href="https://cloudnineapps.com">Cloud Nine Apps</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h1>How To Use AWS CloudWatch With On-Premise Application Components?</h1>
<p>AWS CloudWatch offers centralized logging, monitoring, and analysis to make the developer&#8217;s job easier. A question that comes up for the Enterprise Applications that follow a <strong>hybrid cloud</strong> deployment (that is, one or more of the application components reside on-premise) is how can we use CloudWatch logs for the on-premise components? Is it even possible? The short answer is yes. And, we will see in this post how to do that.</p>
<h2>Why Use CloudWatch For On-Premise Components?</h2>
<p>There are several benefits of using CloudWatch for On-Premise components.</p>
<ul>
<li><strong>Leverage from centralized logging</strong>: You can use the same capabilities for storing the logs centrally for the on-premise components that you are using for the rest of your Cloud-based components.</li>
<li><strong>Time Conversion</strong>: CloudWatch logs are stored in UTC. So, you do not have to worry about tedious conversions, which could often take up your precious time when analyzing logs across several components, especially if these are spread across geographically.</li>
<li><strong>Consistent Analysis</strong>: You can use the same tools and techniques that you are using for Cloud-based components.</li>
<li>Avoid issues like logs rollover or difficult to access logs. Often, on-premise components are managed by customers or other clients that may require some coordination and effort.</li>
</ul>
<h2>How To Publish To CloudWatch Logs From On-Premise Components?</h2>
<p>There are a couple of approaches to accomplish this.</p>
<ol>
<li><strong>Using the AWS CloudWatch Agent to publish logs</strong>: This can be extremely useful for on-premise components that follow an <em>appliance model</em> for deployment (such as a pre-baked image with the application components and dependencies). So, this approach is more configuration-centric and should not require code-level changes. Apart from log collection, the CloudWatch agent can also help in capturing system metrics (such as CPU and memory utilization).</li>
<li><strong>Using the CloudWatch Logs API to publish logs</strong>: This approach requires enhancing the code to use the CloudWatch Logs API to publish logs. Of course, you can make it a reusable module or consider using a third-party library. But, the point is this is a code-centric approach that offers more flexibility.</li>
</ol>
<p>In this post, we will be talking about using the CloudWatch Logs API. If you are interested in using the CloudWatch Agent, please refer to the <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Install-CloudWatch-Agent.html" target="_blank" rel="noopener noreferrer">AWS CloudWatch Agent</a> documentation for details.</p>
<h3>Using The CloudWatch Logs API To Publish Logs</h3>
<p>The following code shows the CloudWatch Logs API usage.</p>
<pre class="lang:default decode:true" title="AWSCloudWatchLogsSampleClient.java">package com.cloudnineapps.samples.aws;

import java.util.ArrayList;
import java.util.List;

import com.amazonaws.auth.AWSCredentialsProvider;
import com.amazonaws.auth.DefaultAWSCredentialsProviderChain;
import com.amazonaws.services.logs.AWSLogsClient;
import com.amazonaws.services.logs.AWSLogsClientBuilder;
import com.amazonaws.services.logs.model.CreateLogGroupRequest;
import com.amazonaws.services.logs.model.CreateLogStreamRequest;
import com.amazonaws.services.logs.model.DescribeLogGroupsRequest;
import com.amazonaws.services.logs.model.DescribeLogGroupsResult;
import com.amazonaws.services.logs.model.DescribeLogStreamsRequest;
import com.amazonaws.services.logs.model.DescribeLogStreamsResult;
import com.amazonaws.services.logs.model.InputLogEvent;
import com.amazonaws.services.logs.model.PutLogEventsRequest;
import com.amazonaws.services.logs.model.PutRetentionPolicyRequest;

/**
 * Sample client for AWS CloudWatch Logs API.
 */
public class AWSCloudWatchLogsSampleClient {

	/** The log group name. */
	private static final String LOG_GROUP = "/myapp/onprem/component-1";

	/** The log stream name. */
	private static final String LOG_STREAM = "app-log";
	
	/** The log retention period (in days). */
	private static final int LOG_RETENTION_PERIOD = 1;

	/** The AWS region. */
	private static String Region = "us-east-1";
	
	/** The CloudWatch client. */
	private static AWSLogsClient Client;
	
	
	/** Opens the CloudWatch log. */
	public static void openCloudWatchLog() throws Exception {
		AWSCredentialsProvider creds = new DefaultAWSCredentialsProviderChain();
		Client = (AWSLogsClient) AWSLogsClientBuilder.standard()
				     .withCredentials(creds)
				     .withRegion(Region)
				     .build();
		// Create and set up the log group if it doesn't exist
		DescribeLogGroupsRequest request = new DescribeLogGroupsRequest().withLogGroupNamePrefix(LOG_GROUP);
		DescribeLogGroupsResult result = Client.describeLogGroups(request);
		if (result.getLogGroups().isEmpty()) {
			CreateLogGroupRequest logGroupRequest = new CreateLogGroupRequest(LOG_GROUP);
			Client.createLogGroup(logGroupRequest);
			PutRetentionPolicyRequest policyRequest = new PutRetentionPolicyRequest(LOG_GROUP, LOG_RETENTION_PERIOD);
			Client.putRetentionPolicy(policyRequest);
			CreateLogStreamRequest logStreamRequest = new CreateLogStreamRequest(LOG_GROUP, LOG_STREAM);
			Client.createLogStream(logStreamRequest);
			log("Created the log group and the log stream.");
		}
	}
	
	/** Logs the specified message. */
	public static void log(String msg) throws Exception {
		// Retrieve the sequence token in the log stream
		DescribeLogStreamsRequest request = new DescribeLogStreamsRequest().withLogGroupName(LOG_GROUP).withLogStreamNamePrefix(LOG_STREAM);
		DescribeLogStreamsResult result = Client.describeLogStreams(request);
		String seqToken = result.getLogStreams().get(0).getUploadSequenceToken();

		// Write to the log stream
		List&lt;InputLogEvent&gt; logEvents = new ArrayList&lt;InputLogEvent&gt;();
		InputLogEvent logEvent = new InputLogEvent().withMessage(msg).withTimestamp(System.currentTimeMillis());
		logEvents.add(logEvent);
		PutLogEventsRequest logRequest = new PutLogEventsRequest(LOG_GROUP, LOG_STREAM, logEvents).withSequenceToken(seqToken);
		Client.putLogEvents(logRequest);
	}
		
	/** Main */
	public static void main(String[] args) throws Exception {
		System.out.println("Launching the application...");
		openCloudWatchLog();
		// Sample log statements
		log("Starting the app...");
		log("Another message");
		System.out.println("Execution completed.");
	}
}
</pre>
<p>Let&#8217;s walk through the code. You can check out the <strong>Resources</strong> section for the complete code (including the maven pom that can be used to compile and execute).</p>
<ul>
<li>The <span style="font-family: courier new, courier, monospace;">main()</span> method invokes the <span style="font-family: courier new, courier, monospace;">openCloudWatchLog()</span> method to initialize the CloudWatch Logs SDK client.</li>
<li>The <span style="font-family: courier new, courier, monospace;">openCloudWatchLog()</span> method checks if the required Log Group (<span style="font-family: courier new, courier, monospace;">/myapp/onprem/component-1</span>) exists using the <span style="font-family: courier new, courier, monospace;">DescribeLogGroupsRequest</span> and the <span style="font-family: courier new, courier, monospace;">Client.describeLogGroups()</span> call. If not, it creates the Log Group using the <span style="font-family: courier new, courier, monospace;">CreateLogGroupRequest</span> and the <span style="font-family: courier new, courier, monospace;">Client.createLogGroup()</span> call. We should always ensure that an appropriate log retention period is set on the log group to avoid accruing a huge log that can lead to a high cost. This is accomplished using the <span style="font-family: courier new, courier, monospace;">PutRetentionPolicyRequest</span> and the <span style="font-family: courier new, courier, monospace;">Client.putRetentionPolicy()</span> call. Then, we create the Log Stream using the <span style="font-family: courier new, courier, monospace;">CreateLogStreamRequest</span> and the <span style="font-family: courier new, courier, monospace;">Client.createLogStream()</span> call. The following screenshot shows the Log Group in the CloudWatch Console.<br />
<a href="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Use_AWS_CloudWatch_With_On-Premise_App_Components/CW_Log_Group.png?ssl=1"><img class="alignnone size-large wp-image-4433" src="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Use_AWS_CloudWatch_With_On-Premise_App_Components/CW_Log_Group.png?resize=640%2C161&#038;ssl=1" alt="" width="640" height="161" srcset="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Use_AWS_CloudWatch_With_On-Premise_App_Components/CW_Log_Group.png?resize=1024%2C257&amp;ssl=1 1024w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Use_AWS_CloudWatch_With_On-Premise_App_Components/CW_Log_Group.png?resize=300%2C75&amp;ssl=1 300w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Use_AWS_CloudWatch_With_On-Premise_App_Components/CW_Log_Group.png?resize=768%2C193&amp;ssl=1 768w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Use_AWS_CloudWatch_With_On-Premise_App_Components/CW_Log_Group.png?resize=320%2C80&amp;ssl=1 320w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Use_AWS_CloudWatch_With_On-Premise_App_Components/CW_Log_Group.png?resize=640%2C161&amp;ssl=1 640w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Use_AWS_CloudWatch_With_On-Premise_App_Components/CW_Log_Group.png?resize=360%2C90&amp;ssl=1 360w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Use_AWS_CloudWatch_With_On-Premise_App_Components/CW_Log_Group.png?resize=720%2C181&amp;ssl=1 720w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Use_AWS_CloudWatch_With_On-Premise_App_Components/CW_Log_Group.png?resize=1080%2C271&amp;ssl=1 1080w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Use_AWS_CloudWatch_With_On-Premise_App_Components/CW_Log_Group.png?resize=800%2C201&amp;ssl=1 800w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Use_AWS_CloudWatch_With_On-Premise_App_Components/CW_Log_Group.png?resize=1280%2C321&amp;ssl=1 1280w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Use_AWS_CloudWatch_With_On-Premise_App_Components/CW_Log_Group.png?w=1474&amp;ssl=1 1474w" sizes="(max-width: 640px) 100vw, 640px" data-recalc-dims="1" /></a></li>
<li>Here is a screenshot of the Log Stream under the Log Group.<br />
<a href="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Use_AWS_CloudWatch_With_On-Premise_App_Components/CW_Log_Streams.png?ssl=1"><img class="alignnone size-large wp-image-4431" src="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Use_AWS_CloudWatch_With_On-Premise_App_Components/CW_Log_Streams.png?resize=640%2C161&#038;ssl=1" alt="" width="640" height="161" srcset="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Use_AWS_CloudWatch_With_On-Premise_App_Components/CW_Log_Streams.png?resize=1024%2C258&amp;ssl=1 1024w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Use_AWS_CloudWatch_With_On-Premise_App_Components/CW_Log_Streams.png?resize=300%2C76&amp;ssl=1 300w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Use_AWS_CloudWatch_With_On-Premise_App_Components/CW_Log_Streams.png?resize=768%2C194&amp;ssl=1 768w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Use_AWS_CloudWatch_With_On-Premise_App_Components/CW_Log_Streams.png?resize=320%2C81&amp;ssl=1 320w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Use_AWS_CloudWatch_With_On-Premise_App_Components/CW_Log_Streams.png?resize=640%2C161&amp;ssl=1 640w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Use_AWS_CloudWatch_With_On-Premise_App_Components/CW_Log_Streams.png?resize=360%2C91&amp;ssl=1 360w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Use_AWS_CloudWatch_With_On-Premise_App_Components/CW_Log_Streams.png?resize=720%2C181&amp;ssl=1 720w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Use_AWS_CloudWatch_With_On-Premise_App_Components/CW_Log_Streams.png?resize=1080%2C272&amp;ssl=1 1080w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Use_AWS_CloudWatch_With_On-Premise_App_Components/CW_Log_Streams.png?resize=800%2C202&amp;ssl=1 800w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Use_AWS_CloudWatch_With_On-Premise_App_Components/CW_Log_Streams.png?resize=1280%2C323&amp;ssl=1 1280w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Use_AWS_CloudWatch_With_On-Premise_App_Components/CW_Log_Streams.png?w=1476&amp;ssl=1 1476w" sizes="(max-width: 640px) 100vw, 640px" data-recalc-dims="1" /></a></li>
<li>Next, the code uses the <span style="font-family: courier new, courier, monospace;">log()</span> method to log sample messages. It uses <span style="font-family: courier new, courier, monospace;">DescribeLogStreamsRequest</span> and the <span style="font-family: courier new, courier, monospace;">Client.describeLogStreams()</span> call to retrieve the Log Stream and fetch the upload sequence token. This token must be included when publishing logs (except for the very first publish). Then, we are creating an <span style="font-family: courier new, courier, monospace;">InputLogEvent</span> with the supplied message and timestamp. The log is published using the <span style="font-family: courier new, courier, monospace;">PutLogEventsRequest</span> and the <span style="font-family: courier new, courier, monospace;">Client.putLogEvents()</span> call. As you might have noticed, you do not have to publish individual log statements. You could very well add multiple <span style="font-family: courier new, courier, monospace;">InputLogEvent</span> objects to publish a batch of logs. The following screenshot demonstrates a sample run of the code.<br />
<a href="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Use_AWS_CloudWatch_With_On-Premise_App_Components/CW_Log_Stream_Content.png?ssl=1"><img class="alignnone size-large wp-image-4432" src="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Use_AWS_CloudWatch_With_On-Premise_App_Components/CW_Log_Stream_Content.png?resize=640%2C230&#038;ssl=1" alt="" width="640" height="230" srcset="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Use_AWS_CloudWatch_With_On-Premise_App_Components/CW_Log_Stream_Content.png?resize=1024%2C368&amp;ssl=1 1024w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Use_AWS_CloudWatch_With_On-Premise_App_Components/CW_Log_Stream_Content.png?resize=300%2C108&amp;ssl=1 300w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Use_AWS_CloudWatch_With_On-Premise_App_Components/CW_Log_Stream_Content.png?resize=768%2C276&amp;ssl=1 768w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Use_AWS_CloudWatch_With_On-Premise_App_Components/CW_Log_Stream_Content.png?resize=320%2C115&amp;ssl=1 320w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Use_AWS_CloudWatch_With_On-Premise_App_Components/CW_Log_Stream_Content.png?resize=640%2C230&amp;ssl=1 640w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Use_AWS_CloudWatch_With_On-Premise_App_Components/CW_Log_Stream_Content.png?resize=360%2C129&amp;ssl=1 360w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Use_AWS_CloudWatch_With_On-Premise_App_Components/CW_Log_Stream_Content.png?resize=720%2C259&amp;ssl=1 720w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Use_AWS_CloudWatch_With_On-Premise_App_Components/CW_Log_Stream_Content.png?resize=1080%2C388&amp;ssl=1 1080w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Use_AWS_CloudWatch_With_On-Premise_App_Components/CW_Log_Stream_Content.png?resize=800%2C288&amp;ssl=1 800w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Use_AWS_CloudWatch_With_On-Premise_App_Components/CW_Log_Stream_Content.png?resize=1280%2C460&amp;ssl=1 1280w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Use_AWS_CloudWatch_With_On-Premise_App_Components/CW_Log_Stream_Content.png?w=1502&amp;ssl=1 1502w" sizes="(max-width: 640px) 100vw, 640px" data-recalc-dims="1" /></a></li>
</ul>
<h3>Using IAM Policy To Restrict Access To Specific Log</h3>
<p>As part of such a setup, it is important to use restrictive access so that the on-premise component can only access the specific log. The good thing is you can enforce this using IAM as follows.</p>
<ul>
<li>Create one or more IAM users for the on-premise components. Grant these users <strong>programmatic access only</strong>.</li>
<li>Create a custom policy (or assign an inline policy) like the one shown below and assign it to the above IAM user(s).</li>
</ul>
<pre class="lang:default decode:true">{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "CloudWatchLogGroupQueryAccess",
            "Effect": "Allow",
            "Action": [
                "logs:DescribeLogGroups"
            ],
            "Resource": "arn:aws:logs:*:*:*"
        },
        {
            "Sid": "CloudWatchLogsAccess",
            "Effect": "Allow",
            "Action": [
                "logs:CreateLogGroup",
                "logs:PutRetentionPolicy",
                "logs:DescribeLogStreams",
                "logs:CreateLogStream",
                "logs:PutLogEvents"
            ],
            "Resource": "arn:aws:logs:*:*:log-group:/myapp/onprem/*:log-stream:*"
        }
    ]
}</pre>
<p>This policy grants access to the required CloudWatch Logs API calls on the on-premise logs only.</p>
<h2>Best Practices For Publishing Logs From On-Premise Components</h2>
<p>The following are some key best practices to consider.</p>
<ul>
<li>Logging can easily get very network intensive. Hence, be quite judicious about which logs are sent to CloudWatch logs. For example, ERROR and WARNING logs are good candidates, but DEBUG is not typically.</li>
<li>Avoid logging any sensitive data. This is critical, and often not as well thought. For example, some of the things to avoid are logging passwords in plain text, users&#8217; Personally Identifiable Information (PII), and so on.</li>
<li>Always set an appropriate log retention period on the Log Group.</li>
<li>Use a well-defined naming convention for the Log Group and Log Streams. For example, <span style="font-family: courier new, courier, monospace;">/myapp/onprem/component-1</span>.</li>
<li>Use a restrictive IAM policy for the user that is used to publish logs, and ensure it has access to the component-specific logs only.</li>
<li>Prefer using application-specific IAM user(s) for logging across multiple applications. This way, you can track and manage access better.</li>
</ul>
<h2>Conclusion</h2>
<p>When designing hybrid cloud or on-premise components, evaluate publishing logs to CloudWatch. By following a few key best practices to ensure this is done in a manner that meets the application needs as well as enterprise readiness considerations like security and performance, this can be quite helpful in pro-active application monitoring and management.</p>
<h2>Resources</h2>
<ul>
<li><a href="https://github.com/cloudnineapps/AWSCloudWatchLogsSampleClient" target="_blank" rel="noopener noreferrer">AWSCloudWatchLogsSampleClient GitHub Repository</a></li>
</ul>
<p>&nbsp;</p>
<p>Happy logging!<br />
&#8211; Nitin</p>
<p><em>If you liked this post, you will find my <a href="https://cloudnineapps.com/courses/cloud-computing/aws-advanced-for-developers/" rel="noopener noreferrer">AWS Advanced For Developers</a> course helpful that focuses on many such best practices and techniques to design and deploy real-world applications in AWS.</em></p>
<p><div class="su-note"  style="border-color:#e5d6d4;border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px;"><div class="su-note-inner su-u-clearfix su-u-trim" style="background-color:#fff0ee;border-color:#ffffff;color:#333333;border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px;"></p>
<center>
<h4>Enhance your AWS skills with these hands-on courses for real-world deployments.</h4>
</center>
<p><div class="su-row"> <div class="su-column su-column-size-1-2"><div class="su-column-inner su-u-clearfix su-u-trim"></p>
<p><a href="https://cloudnineapps.com/courses/cloud-computing/aws-cloudformation-deep-dive/"><img class="aligncenter wp-image-3758 size-medium" src="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/courses/Cloud_Computing/AWS_CloudFormation_Deep_Dive/AWS_CloudFormation_Deep_Dive_Logo.png?resize=192%2C108&#038;ssl=1" alt="" width="192" height="108" data-recalc-dims="1" /></a></p>
<center>Learn CloudFormation from concepts to hands-on examples.</center>
<p></div></div> <div class="su-column su-column-size-1-2"><div class="su-column-inner su-u-clearfix su-u-trim"></p>
<p><a href="https://cloudnineapps.com/courses/cloud-computing/aws-advanced-for-developers/"><img class="size-full wp-image-2068 aligncenter" src="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/courses/Cloud_Computing/AWS_Advanced_For_Developers/AWS_Advanced_For_Developers_Logo_small.png?resize=192%2C108&#038;ssl=1" alt="" width="192" height="108" data-recalc-dims="1" /></a></p>
<center>Learn practical application development on AWS.</center>
<p></div></div> </div></div></div></p>
<p>&nbsp;</p>
<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fhow-to-use-aws-cloudwatch-with-on-premise-application-components%2F&amp;linkname=How%20To%20Use%20AWS%20CloudWatch%20With%20On-Premise%20Application%20Components%3F" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fhow-to-use-aws-cloudwatch-with-on-premise-application-components%2F&amp;linkname=How%20To%20Use%20AWS%20CloudWatch%20With%20On-Premise%20Application%20Components%3F" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fhow-to-use-aws-cloudwatch-with-on-premise-application-components%2F&amp;linkname=How%20To%20Use%20AWS%20CloudWatch%20With%20On-Premise%20Application%20Components%3F" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fhow-to-use-aws-cloudwatch-with-on-premise-application-components%2F&amp;linkname=How%20To%20Use%20AWS%20CloudWatch%20With%20On-Premise%20Application%20Components%3F" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd a2a_counter addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fhow-to-use-aws-cloudwatch-with-on-premise-application-components%2F&#038;title=How%20To%20Use%20AWS%20CloudWatch%20With%20On-Premise%20Application%20Components%3F" data-a2a-url="https://cloudnineapps.com/blogs/cloud-computing/how-to-use-aws-cloudwatch-with-on-premise-application-components/" data-a2a-title="How To Use AWS CloudWatch With On-Premise Application Components?"></a></p><p>The post <a rel="nofollow" href="https://cloudnineapps.com/blogs/cloud-computing/how-to-use-aws-cloudwatch-with-on-premise-application-components/">How To Use AWS CloudWatch With On-Premise Application Components?</a> appeared first on <a rel="nofollow" href="https://cloudnineapps.com">Cloud Nine Apps</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://cloudnineapps.com/blogs/cloud-computing/how-to-use-aws-cloudwatch-with-on-premise-application-components/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">4424</post-id>	</item>
		<item>
		<title>How To Create A Multi-Tier Stack Using AWS CloudFormation</title>
		<link>https://cloudnineapps.com/blogs/cloud-computing/how-to-create-a-multi-tier-stack-using-aws-cloudformation/</link>
					<comments>https://cloudnineapps.com/blogs/cloud-computing/how-to-create-a-multi-tier-stack-using-aws-cloudformation/#respond</comments>
		
		<dc:creator><![CDATA[Nitin Patil]]></dc:creator>
		<pubDate>Wed, 01 Jan 2020 11:24:08 +0000</pubDate>
				<category><![CDATA[Cloud Computing]]></category>
		<guid isPermaLink="false">https://cloudnineapps.com/?p=4405</guid>

					<description><![CDATA[<p>How To Create A Multi-tier Stack Using AWS CloudFormation? AWS CloudFormation (CFN) makes it easy to deploy and manage your application infrastructure as an atomic unit using CloudFormation templates. In this article, we will cover how to use CFN to&#8230;&#160;<a href="https://cloudnineapps.com/blogs/cloud-computing/how-to-create-a-multi-tier-stack-using-aws-cloudformation/" class="more-link">Read More</a></p>
<p>The post <a rel="nofollow" href="https://cloudnineapps.com/blogs/cloud-computing/how-to-create-a-multi-tier-stack-using-aws-cloudformation/">How To Create A Multi-Tier Stack Using AWS CloudFormation</a> appeared first on <a rel="nofollow" href="https://cloudnineapps.com">Cloud Nine Apps</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h1>How To Create A Multi-tier Stack Using AWS CloudFormation?</h1>
<p>AWS CloudFormation (CFN) makes it easy to deploy and manage your application infrastructure as an atomic unit using CloudFormation templates. In this article, we will cover how to use CFN to create a multi-tier stack. We will also see how to handle different deployment variations, such as a full-blown production stack with a load balancer, and a smaller footprint development stack using the same CFN template! Lastly, I will also highlight some important tips when designing the CFN templates for your applications.</p>
<p><span style="text-decoration: underline;">Note</span>: If you are new to CloudFormation, I highly recommend reading the <a href="https://medium.com/swlh/aws-cloudformation-an-architects-best-friend-79526f60abf1" target="_blank" rel="nofollow noreferrer noopener">AWS CloudFormation &#8211; An Architect&#8217;s Best Friend</a> first to familiarize yourself with the basics.</p>
<h2>Identify The Application Deployment Models</h2>
<p>Before you start designing the CFN template, it is important to understand in which all possible ways the application can be deployed. At a minimum, identify the key deployment models. For example, what would a typical development deployment look like? Which resources would be needed and what are their configurations? Likewise, for production. Having these details upfront has several benefits.</p>
<ul>
<li>You will have a clear understanding of the legitimate combinations in which the application can be deployed.</li>
<li>You can then delve into the resource configurations and addressing other key aspects like security.</li>
<li>Lastly, you can ensure that the deployment models are as cost-optimal as possible. For example, the development stack may have the smallest footprint possible to keep cost low versus the production stack that may have a larger footprint.</li>
</ul>
<p>Let&#8217;s take a look at our sample multi-tier stack.</p>
<p><a href="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_A_Multi-Tier_Stack_Using_AWS_CloudFormation/Multi_Tier_Stack.png?ssl=1" target="_blank" rel="noopener noreferrer"><img class="alignright wp-image-4409 size-medium" src="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_A_Multi-Tier_Stack_Using_AWS_CloudFormation/Multi_Tier_Stack.png?resize=219%2C300&#038;ssl=1" alt="" width="219" height="300" srcset="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_A_Multi-Tier_Stack_Using_AWS_CloudFormation/Multi_Tier_Stack.png?resize=219%2C300&amp;ssl=1 219w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_A_Multi-Tier_Stack_Using_AWS_CloudFormation/Multi_Tier_Stack.png?resize=768%2C1051&amp;ssl=1 768w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_A_Multi-Tier_Stack_Using_AWS_CloudFormation/Multi_Tier_Stack.png?resize=748%2C1024&amp;ssl=1 748w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_A_Multi-Tier_Stack_Using_AWS_CloudFormation/Multi_Tier_Stack.png?resize=320%2C438&amp;ssl=1 320w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_A_Multi-Tier_Stack_Using_AWS_CloudFormation/Multi_Tier_Stack.png?resize=640%2C876&amp;ssl=1 640w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_A_Multi-Tier_Stack_Using_AWS_CloudFormation/Multi_Tier_Stack.png?resize=360%2C493&amp;ssl=1 360w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_A_Multi-Tier_Stack_Using_AWS_CloudFormation/Multi_Tier_Stack.png?resize=720%2C986&amp;ssl=1 720w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_A_Multi-Tier_Stack_Using_AWS_CloudFormation/Multi_Tier_Stack.png?resize=197%2C270&amp;ssl=1 197w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_A_Multi-Tier_Stack_Using_AWS_CloudFormation/Multi_Tier_Stack.png?resize=300%2C411&amp;ssl=1 300w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_A_Multi-Tier_Stack_Using_AWS_CloudFormation/Multi_Tier_Stack.png?w=770&amp;ssl=1 770w" sizes="(max-width: 219px) 100vw, 219px" data-recalc-dims="1" /></a></p>
<ul>
<li>For the sake of discussion, we will cover 2 deployment models: Development and Production.</li>
<li>The <strong>Production</strong> deployment will comprise of a public-facing load balancer, which will be backed by 2 web-tier EC2 instances running Apache. These instances will talk to the EC2 instance hosting the app-tier running tomcat.</li>
<li>Security Groups will be used for access control. The <span style="font-family: courier new, courier, monospace;">PublicWebSecurityGroup</span> will be assigned to the web-tier and the <span style="font-family: courier new, courier, monospace;">AppSecurityGroup</span> will be assigned to the app-tier. Now, you may have noticed the <span style="font-family: courier new, courier, monospace;">PrivateWebSecurityGroup</span>. Can you guess what&#8217;s that for? Perhaps you got it. It is the Security Group created for the Production stack to ensure that the web-tier EC2 instances are only accessible via the load balancer and not exposed publicly.</li>
<li>The <strong>Development</strong> deployment of the stack will comprise of a single web-tier EC2 instance and a single app-tier EC2 instance.</li>
</ul>
<p>So, as you can see, this seemingly simple stack deployment can also become complex considering the different deployment models. But, not to worry. CFN provides us several useful capabilities to make this work.</p>
<h2>The Multi-Tier Stack CFN Template</h2>
<p>Here is the CFN template.</p>
<pre class="lang:default decode:true" title="Multi_Tier_Stack.json">{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Description": "A multi-tier stack instance.",
  "Parameters": {
    "DeploymentType": {
      "Description": "The deployment type.",
      "Type": "String",
      "AllowedValues": ["Development", "Production"],
      "Default": "Development"
    },
    "VPC": {
      "Description": "The VPC for the EC2 instances.",
      "Type": "AWS::EC2::VPC::Id"
    },
    "Subnet1": {
      "Description": "The subnet1 for the EC2 instances.",
      "Type": "AWS::EC2::Subnet::Id"
    },
    "Subnet2": {
      "Description": "The subnet2 for the EC2 instances.",
      "Type": "AWS::EC2::Subnet::Id"
    },
    "SSHSecurityGroup": {
      "Description": "The SSH Security Group for the EC2 instances.",
      "Type": "AWS::EC2::SecurityGroup::Id"
    },
    "KeyPair": {
      "Description": "The key pair name to use to connect to the EC2 instances.",
      "Type": "String"
    }
  },
  "Mappings": {
    "Globals": {
      "Constants": {
        "ImageId": "ami-0b898040803850657",
        "AssignPublicIP": "true",
        "WebInstanceSuffix": "web",
        "AppInstanceSuffix": "app"
      }
    },
    "DeploymentTypes": {
      "Development": {
        "InstanceType": "t2.small",
        "StorageSize": "20"
      },
      "Production": {
        "InstanceType": "t2.medium",
        "StorageSize": "50"
      }
    }
  },
  "Conditions": {
    "CreateMultipleInstances": {"Fn::Not": [{"Fn::Equals": ["Development", {"Ref": "DeploymentType"}]}]}
  },
  "Resources": {
    "LoadBalancer": {
      "Type": "AWS::ElasticLoadBalancing::LoadBalancer",
      "Condition": "CreateMultipleInstances",
      "Properties": {
        "Instances": [{"Ref": "Web1EC2Instance"}, {"Ref": "Web2EC2Instance"}],
        "Subnets": [{"Ref": "Subnet1"}, {"Ref": "Subnet2"}],
        "SecurityGroups": [{"Ref": "PublicWebSecurityGroup"}],
        "Listeners": [{
          "LoadBalancerPort": 80,
          "InstancePort": 80,
          "Protocol": "HTTP"
        }],
        "HealthCheck": {
          "Target": "HTTP:80/",
          "HealthyThreshold": "3",
          "UnhealthyThreshold": "5",
          "Interval": "10",
          "Timeout": "3"
        }
      },
      "Metadata": {
        "AWS::CloudFormation::Designer": {
          "id": "fbf8f065-5dc7-4850-bb4f-8c4287a8cb7b"
        }
      }
    },
    "Web1EC2Instance": {
      "Type": "AWS::EC2::Instance",
      "Properties": {
        "ImageId": {"Fn::FindInMap": ["Globals", "Constants", "ImageId"]},
        "InstanceType": {"Fn::FindInMap": ["DeploymentTypes", {"Ref": "DeploymentType"}, "InstanceType"]},
        "NetworkInterfaces": [{
          "DeviceIndex": "0",
          "SubnetId": {"Ref": "Subnet1"},
          "AssociatePublicIpAddress": {"Fn::FindInMap": ["Globals", "Constants", "AssignPublicIP"]},
          "GroupSet": [{"Ref": "SSHSecurityGroup"}, {"Fn::If": ["CreateMultipleInstances", {"Ref": "PrivateWebSecurityGroup"}, {"Ref": "PublicWebSecurityGroup"}]}]
        }],
        "BlockDeviceMappings": [{
          "DeviceName": "/dev/sdm",
          "Ebs": {
            "VolumeType": "gp2",
            "VolumeSize": {"Fn::FindInMap": ["DeploymentTypes", {"Ref": "DeploymentType"}, "StorageSize"]},
            "DeleteOnTermination": "true"
          }
        }],
        "KeyName": {"Ref": "KeyPair"},
        "Tags": [{"Key": "Name", "Value": {"Fn::Join": ["-", [{"Ref": "AWS::StackName"}, {"Fn::FindInMap": ["Globals", "Constants", "WebInstanceSuffix"]}, "1"]]}}],
        "UserData": {"Fn::Base64": {"Fn::Join": ["", [
          "#!/bin/bash\n",
          "yum install -y aws-cfn-bootstrap\n",
          "\n",
          "# Install the software\n",
          "/opt/aws/bin/cfn-init -v",
          " --stack ", {"Ref": "AWS::StackName"},
          " --resource Web1EC2Instance",
          " --configsets Install",
          " --region ", {"Ref": "AWS::Region"}, "\n",
          "\n",
          "# Signal resource creation completion\n",
          "/opt/aws/bin/cfn-signal -e $?",
          " --stack ", {"Ref": "AWS::StackName"},
          " --resource Web1EC2Instance",
          " --region ", {"Ref": "AWS::Region"}, "\n"
        ]]}}
      },
      "CreationPolicy": {
        "ResourceSignal": {
          "Count": 1,
          "Timeout": "PT5M"
        }
      },
      "DependsOn": "AppEC2Instance",
      "Metadata": {
        "AWS::CloudFormation::Designer": {
          "id": "83fb66e0-bfdf-4076-9d59-3f1077f47a2a"
        },
        "AWS::CloudFormation::Init": {
          "configSets": {
            "Install": ["Install"]
          },
          "Install": {
            "packages": {
              "yum": {
                "httpd": []
              }
            },
            "files": {
              "/var/www/html/index.html": {
                "content": {"Fn::Join": ["", [
                  "&lt;html&gt;\n",
                  "  &lt;head&gt;\n",
                  "    &lt;title&gt;Welcome to a sample multi-tier app!&lt;/title&gt;\n",
                  "  &lt;/head&gt;\n",
                  "  &lt;body&gt;\n",
                  "    &lt;h1&gt;Welcome to a sample multi-tier app!&lt;/h1&gt;\n",
                  "  &lt;/body&gt;\n",
                  "&lt;/html&gt;\n"
                ]]},
                "mode": "0600",
                "owner": "apache",
                "group": "apache"
              }
            },
            "services": {
              "sysvinit": {
                "httpd": {"enabled": "true", "ensureRunning": "true"}
              }
            }
          }
        }
      }
    },
    "Web2EC2Instance": {
      "Type": "AWS::EC2::Instance",
      "Condition": "CreateMultipleInstances",
      "Properties": {
        "ImageId": {"Fn::FindInMap": ["Globals", "Constants", "ImageId"]},
        "InstanceType": {"Fn::FindInMap": ["DeploymentTypes", {"Ref": "DeploymentType"}, "InstanceType"]},
        "NetworkInterfaces": [{
          "DeviceIndex": "0",
          "SubnetId": {"Ref": "Subnet2"},
          "AssociatePublicIpAddress": {"Fn::FindInMap": ["Globals", "Constants", "AssignPublicIP"]},
          "GroupSet": [{"Ref": "SSHSecurityGroup"}, {"Ref": "PrivateWebSecurityGroup"}]
        }],
        "BlockDeviceMappings": [{
          "DeviceName": "/dev/sdm",
          "Ebs": {
            "VolumeType": "gp2",
            "VolumeSize": {"Fn::FindInMap": ["DeploymentTypes", {"Ref": "DeploymentType"}, "StorageSize"]},
            "DeleteOnTermination": "true"
          }
        }],
        "KeyName": {"Ref": "KeyPair"},
        "Tags": [{"Key": "Name", "Value": {"Fn::Join": ["-", [{"Ref": "AWS::StackName"}, {"Fn::FindInMap": ["Globals", "Constants", "WebInstanceSuffix"]}, "2"]]}}],
        "UserData": {"Fn::Base64": {"Fn::Join": ["", [
          "#!/bin/bash\n",
          "yum install -y aws-cfn-bootstrap\n",
          "\n",
          "# Install the software\n",
          "/opt/aws/bin/cfn-init -v",
          " --stack ", {"Ref": "AWS::StackName"},
          " --resource Web2EC2Instance",
          " --configsets Install",
          " --region ", {"Ref": "AWS::Region"}, "\n",
          "\n",
          "# Signal resource creation completion\n",
          "/opt/aws/bin/cfn-signal -e $?",
          " --stack ", {"Ref": "AWS::StackName"},
          " --resource Web2EC2Instance",
          " --region ", {"Ref": "AWS::Region"}, "\n"
        ]]}}
      },
      "CreationPolicy": {
        "ResourceSignal": {
          "Count": 1,
          "Timeout": "PT5M"
        }
      },
      "DependsOn": "AppEC2Instance",
      "Metadata": {
        "AWS::CloudFormation::Designer": {
          "id": "4e1f2401-833d-442d-be04-89fac2d74778"
        },
        "AWS::CloudFormation::Init": {
          "configSets": {
            "Install": ["Install"]
          },
          "Install": {
            "packages": {
              "yum": {
                "httpd": []
              }
            },
            "files": {
              "/var/www/html/index.html": {
                "content": {"Fn::Join": ["", [
                  "&lt;html&gt;\n",
                  "  &lt;head&gt;\n",
                  "    &lt;title&gt;Welcome to a sample multi-tier app!&lt;/title&gt;\n",
                  "  &lt;/head&gt;\n",
                  "  &lt;body&gt;\n",
                  "    &lt;h1&gt;Welcome to a sample multi-tier app!&lt;/h1&gt;\n",
                  "  &lt;/body&gt;\n",
                  "&lt;/html&gt;\n"
                ]]},
                "mode": "0600",
                "owner": "apache",
                "group": "apache"
              }
            },
            "services": {
              "sysvinit": {
                "httpd": {"enabled": "true", "ensureRunning": "true"}
              }
            }
          }
        }
      }
    },
    "AppEC2Instance": {
      "Type": "AWS::EC2::Instance",
      "Properties": {
        "ImageId": {"Fn::FindInMap": ["Globals", "Constants", "ImageId"]},
        "InstanceType": {"Fn::FindInMap": ["DeploymentTypes", {"Ref": "DeploymentType"}, "InstanceType"]},
        "NetworkInterfaces": [{
          "DeviceIndex": "0",
          "SubnetId": {"Ref": "Subnet1"},
          "AssociatePublicIpAddress": {"Fn::FindInMap": ["Globals", "Constants", "AssignPublicIP"]},
          "GroupSet": [{"Ref": "SSHSecurityGroup"}, {"Ref": "AppSecurityGroup"}]
        }],
        "BlockDeviceMappings": [{
          "DeviceName": "/dev/sdm",
          "Ebs": {
            "VolumeType": "gp2",
            "VolumeSize": {"Fn::FindInMap": ["DeploymentTypes", {"Ref": "DeploymentType"}, "StorageSize"]},
            "DeleteOnTermination": "true"
          }
        }],
        "KeyName": {"Ref": "KeyPair"},
        "Tags": [{"Key": "Name", "Value": {"Fn::Join": ["-", [{"Ref": "AWS::StackName"}, {"Fn::FindInMap": ["Globals", "Constants", "AppInstanceSuffix"]}, "1"]]}}],
        "UserData": {"Fn::Base64": {"Fn::Join": ["", [
          "#!/bin/bash\n",
          "yum install -y aws-cfn-bootstrap\n",
          "\n",
          "# Install the software\n",
          "/opt/aws/bin/cfn-init -v",
          " --stack ", {"Ref": "AWS::StackName"},
          " --resource AppEC2Instance",
          " --configsets Install",
          " --region ", {"Ref": "AWS::Region"}, "\n",
          "\n",
          "# Signal resource creation completion\n",
          "/opt/aws/bin/cfn-signal -e $?",
          " --stack ", {"Ref": "AWS::StackName"},
          " --resource AppEC2Instance",
          " --region ", {"Ref": "AWS::Region"}, "\n"
        ]]}}
      },
      "CreationPolicy": {
        "ResourceSignal": {
          "Count": 1,
          "Timeout": "PT5M"
        }
      },
      "Metadata": {
        "AWS::CloudFormation::Designer": {
          "id": "4720705c-1add-4c63-abd6-d9fd4626a43d"
        },
        "AWS::CloudFormation::Init": {
          "configSets": {
            "Install": ["Install"]
          },
          "Install": {
            "packages": {
              "yum": {
                "tomcat": [],
                "tomcat-webapps": []
              }
            },
            "services": {
              "sysvinit": {
                "tomcat": {"enabled": "true", "ensureRunning": "true"}
              }
            }
          }
        }
      }
    },
    "PublicWebSecurityGroup": {
      "Type": "AWS::EC2::SecurityGroup",
      "Properties": {
        "GroupName": {"Fn::Join": ["-", [{"Ref": "AWS::StackName"}, "public-web-sg"]]},
        "GroupDescription": {"Fn::Join": ["", ["Enables public web access for ", {"Ref": "AWS::StackName"}, "."]]},
        "VpcId": {"Ref": "VPC"},
        "SecurityGroupIngress": [
          {"IpProtocol": "tcp", "FromPort": "80", "ToPort": "80", "CidrIp": "0.0.0.0/0"}
        ],
        "Tags": [{"Key": "Name", "Value": {"Fn::Join": ["-", [{"Ref": "AWS::StackName"}, "public-web-sg"]]}}]
      },
      "Metadata": {
        "AWS::CloudFormation::Designer": {
          "id": "bfef096b-3b53-4799-b880-0df21011e7ed"
        }
      }
    },
    "PrivateWebSecurityGroup": {
      "Type": "AWS::EC2::SecurityGroup",
      "Properties": {
        "GroupName": {"Fn::Join": ["-", [{"Ref": "AWS::StackName"}, "private-web-sg"]]},
        "GroupDescription": {"Fn::Join": ["", ["Enables private web access for ", {"Ref": "AWS::StackName"}, "."]]},
        "VpcId": {"Ref": "VPC"},
        "SecurityGroupIngress": [
          {"IpProtocol": "tcp", "FromPort": "80", "ToPort": "80", "SourceSecurityGroupId": {"Ref": "PublicWebSecurityGroup"}}
        ],
        "Tags": [{"Key": "Name", "Value": {"Fn::Join": ["-", [{"Ref": "AWS::StackName"}, "private-web-sg"]]}}]
      },
      "Metadata": {
        "AWS::CloudFormation::Designer": {
          "id": "f00bae41-3fe2-41c1-ad14-64680744f71f"
        }
      }
    },
    "AppSecurityGroup": {
      "Type": "AWS::EC2::SecurityGroup",
      "Properties": {
        "GroupName": {"Fn::Join": ["-", [{"Ref": "AWS::StackName"}, "app-sg"]]},
        "GroupDescription": {"Fn::Join": ["", ["Enables access to ", {"Ref": "AWS::StackName"}, " app tier."]]},
        "VpcId": {"Ref": "VPC"},
        "SecurityGroupIngress": [
          {"IpProtocol": "tcp", "FromPort": "8080", "ToPort": "8080", "SourceSecurityGroupId": {"Fn::If": ["CreateMultipleInstances", {"Ref": "PrivateWebSecurityGroup"}, {"Ref": "PublicWebSecurityGroup"}]}}
        ],
        "Tags": [{"Key": "Name", "Value": {"Fn::Join": ["-", [{"Ref": "AWS::StackName"}, "app-sg"]]}}]
      },
      "Metadata": {
        "AWS::CloudFormation::Designer": {
          "id": "adf9b8b7-25c4-4ddb-9401-e5c34da55511"
        }
      }
    }
  },
  "Outputs": {
    "StackURL": {
      "Description": "The stack web URL.",
      "Value": {"Fn::Join": ["", ["http://",
          {"Fn::If": ["CreateMultipleInstances", {"Fn::GetAtt": ["LoadBalancer", "DNSName"]}, {"Fn::GetAtt": ["Web1EC2Instance", "PublicIp"]}]}
      ]]}
    }
  },
  "Metadata": {
    "AWS::CloudFormation::Designer": {
      "fbf8f065-5dc7-4850-bb4f-8c4287a8cb7b": {
        "size": {
          "width": 60,
          "height": 60
        },
        "position": {
          "x": 560,
          "y": 50
        },
        "z": 0,
        "embeds": [],
        "isassociatedwith": [
          "83fb66e0-bfdf-4076-9d59-3f1077f47a2a",
          "4e1f2401-833d-442d-be04-89fac2d74778",
          "bfef096b-3b53-4799-b880-0df21011e7ed"
        ]
      },
      "83fb66e0-bfdf-4076-9d59-3f1077f47a2a": {
        "size": {
          "width": 60,
          "height": 60
        },
        "position": {
          "x": 470,
          "y": 150
        },
        "z": 0,
        "embeds": []
      },
      "4e1f2401-833d-442d-be04-89fac2d74778": {
        "size": {
          "width": 60,
          "height": 60
        },
        "position": {
          "x": 650,
          "y": 150
        },
        "z": 0,
        "embeds": []
      },
      "bfef096b-3b53-4799-b880-0df21011e7ed": {
        "size": {
          "width": 60,
          "height": 60
        },
        "position": {
          "x": 460,
          "y": 50
        },
        "z": 0,
        "embeds": []
      },
      "c4db756b-b07b-4324-be5f-6ed116047ed8": {
        "source": {
          "id": "fbf8f065-5dc7-4850-bb4f-8c4287a8cb7b"
        },
        "target": {
          "id": "bfef096b-3b53-4799-b880-0df21011e7ed"
        },
        "z": 11
      },
      "4720705c-1add-4c63-abd6-d9fd4626a43d": {
        "size": {
          "width": 60,
          "height": 60
        },
        "position": {
          "x": 553,
          "y": 265
        },
        "z": 0,
        "embeds": []
      },
      "a60d3d35-5a1d-4a58-a2bd-6f5ffe94017a": {
        "source": {
          "id": "83fb66e0-bfdf-4076-9d59-3f1077f47a2a"
        },
        "target": {
          "id": "4720705c-1add-4c63-abd6-d9fd4626a43d"
        },
        "z": 11
      },
      "f00bae41-3fe2-41c1-ad14-64680744f71f": {
        "size": {
          "width": 60,
          "height": 60
        },
        "position": {
          "x": 660,
          "y": 270
        },
        "z": 1,
        "embeds": []
      },
      "adf9b8b7-25c4-4ddb-9401-e5c34da55511": {
        "size": {
          "width": 60,
          "height": 60
        },
        "position": {
          "x": 540,
          "y": 360
        },
        "z": 1,
        "embeds": []
      },
      "5f28f4f3-edee-437e-856b-dda339912a82": {
        "source": {
          "id": "4720705c-1add-4c63-abd6-d9fd4626a43d"
        },
        "target": {
          "id": "adf9b8b7-25c4-4ddb-9401-e5c34da55511"
        },
        "z": 11
      }
    }
  }
}

</pre>
<p>Let&#8217;s break it down by section to understand it better.</p>
<h3>Template Parameters</h3>
<ul>
<li>The <span style="font-family: courier new, courier, monospace;">DeploymentType</span> parameter is used to determine the deployment model. Such logical parameters are extremely useful as compared to exposing the individual resource properties as parameters. Why? Firstly, these enable the CFN template designer to ensure that the deployments meet only the prescribed models. Secondly, these hide unnecessary complexities from the template users. Also, tomorrow if you add more resources or change configurations, the template users do not have to be bothered about these.</li>
<li>The next 3 parameters take the target VPC and subnet information. Note that because we are doing a Production deployment we do want to leverage from the high availability capabilities offered by AWS so that we can distribute our EC2 instances across multiple Availability Zones.</li>
<li>The <span style="font-family: courier new, courier, monospace;">SSHSecurityGroup</span> parameter is used to specify the Security Group that will be used to connect to the EC2 instances. Now, you could very well create a Security Group for SSH in this template itself. However, I wanted to demonstrate the use of a Security Group that has been created by the networking team for access control. For example, they may set up the SSH Security Group to only allow inbound traffic from the corporate network. So, as opposed to every application team coming up with their own SSH Security Group, here the organization has chosen to use the same SSH Security Group for consistency and ease of management. These considerations are quite important when you design CFN templates. You want to ensure you are not creating backdoors that could lead to a potential security breach.</li>
<li>The <span style="font-family: courier new, courier, monospace;">KeyPair</span> parameter specifies the SSH key pair name that will be used for connecting to the EC2 instances.</li>
</ul>
<h3>Mappings</h3>
<ul>
<li>The <span style="font-family: courier new, courier, monospace;">Globals</span> map defines constants to avoid hardcoding values all over the template. For example, instead of hardcoding the AMI ID everywhere, we can simply define it once here. Tomorrow, if we want to change it, we just have to update it in one place. Likewise, the other constants.</li>
<li>The <span style="font-family: courier new, courier, monospace;">DeploymentTypes</span> map specifies the resource properties for each deployment model. For example, a Development EC2 instance will use <span style="font-family: courier new, courier, monospace;">t2.small</span> instance type. Whereas, a Production EC2 instance will use <span style="font-family: courier new, courier, monospace;">t2.medium</span>.</li>
</ul>
<h3>Conditions</h3>
<ul>
<li>The <span style="font-family: courier new, courier, monospace;">CreateMultipleInstances</span> condition is set to true only if it is NOT a Development deployment. This will be used later in the template when creating the resources. If you are wondering why I didn&#8217;t call it <span style="font-family: courier new, courier, monospace;">IsProductionDeployment</span>, there is a good reason. What if I add another deployment model tomorrow called <span style="font-family: courier new, courier, monospace;">QA</span>, which also has multiple instances? By keeping the condition name more generic, we can use it for both these deployment models.</li>
</ul>
<h3>Resources</h3>
<p>Notice the use of <span style="font-family: courier new, courier, monospace;">DependsOn</span> to ensure the resources are created in the correct order.</p>
<ul>
<li>First, it creates a load balancer (LB) for the web-tier if the <span style="font-family: courier new, courier, monospace;">CreateMultipleInstances</span> condition is true. This LB will have 2 EC2 instances attached &#8211; <span style="font-family: courier new, courier, monospace;">Web1EC2Instance</span> and <span style="font-family: courier new, courier, monospace;">Web2EC2Instance</span>. It will have access to the specified subnets and will be assigned the <span style="font-family: courier new, courier, monospace;">PublicWebSecurityGroup</span>. The LB will listen on port <span style="font-family: courier new, courier, monospace;">80</span> (HTTP) and will forward traffic to port <span style="font-family: courier new, courier, monospace;">80</span> on the EC2 instances. As we know, LB works by checking the health of the underlying instances. In this case, it will access the base URL (<span style="font-family: courier new, courier, monospace;">/</span>) every <span style="font-family: courier new, courier, monospace;">10 seconds</span> with a timeout value of <span style="font-family: courier new, courier, monospace;">3 seconds</span>. If the health check fails <span style="font-family: courier new, courier, monospace;">5</span> consecutive times, the instance will be declared unhealthy. And, the check must succeed <span style="font-family: courier new, courier, monospace;">3</span> consecutive times to declare the instance as healthy.</li>
<li>Next, it creates the <span style="font-family: courier new, courier, monospace;">Web1EC2Instance</span>. It uses the <span style="font-family: courier new, courier, monospace;">Globals</span> map to find some property values like the AMI ID. The <span style="font-family: courier new, courier, monospace;">InstanceType</span> is set based on the <span style="font-family: courier new, courier, monospace;">DeploymentType</span>. If it is a Production EC2 instance, it will be assigned the <span style="font-family: courier new, courier, monospace;">PrivateWebSecurityGroup</span> to avoid direct public access. For Development, it will be assigned the <span style="font-family: courier new, courier, monospace;">PublicWebSecurityGroup</span>. Also, the SSH Security Group will be assigned. The instance will have a single EBS volume attached. Apart from <span style="font-family: courier new, courier, monospace;">KeyName</span> and <span style="font-family: courier new, courier, monospace;">Tags</span>, notice the use of <span style="font-family: courier new, courier, monospace;">UserData</span>. This is used to install and configure the apache daemon when the instance first boots using the <a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-helper-scripts-reference.html" target="_blank" rel="nofollow noopener noreferrer">AWS CFN Helper Scripts</a>. The <span style="font-family: courier new, courier, monospace;">Metadata</span> section contains the information used by these scripts to do their work. The <span style="font-family: courier new, courier, monospace;">CreationPolicy</span> is used to ensure that CFN waits till it receives a success or failure signal from the <span style="font-family: courier new, courier, monospace;">UserData</span> script with a timeout of <span style="font-family: courier new, courier, monospace;">5 minutes</span>. Note that <span style="font-family: courier new, courier, monospace;">Web1EC2Instance</span> is created regardless of the <span style="font-family: courier new, courier, monospace;">DeploymentType</span> since the stack will have at least one web-tier instance.</li>
<li>The <span style="font-family: courier new, courier, monospace;">Web2EC2Instance</span> is created only if the <span style="font-family: courier new, courier, monospace;">CreateMultipleInstances</span> condition is set to true. Its configuration is the same as the <span style="font-family: courier new, courier, monospace;">Web1EC2Instance</span>.</li>
<li>The <span style="font-family: courier new, courier, monospace;">AppEC2Instance</span> is created similarly with the key difference being it will be assigned the <span style="font-family: courier new, courier, monospace;">AppSecurityGroup</span> and tomcat will be installed on it. Note that just like the web-tier we could create multiple EC2 instances for the app-tier and put an LB in-front of these for high availability and load balancing purposes. But, I&#8217;ve skipped that part here for brevity purposes.</li>
<li>Next, it creates the Security Groups for the respective tiers. Notice how the <span style="font-family: courier new, courier, monospace;">PrivateWebSecurityGroup</span> sets its ingress rule to permit traffic only from the source resource that has the <span style="font-family: courier new, courier, monospace;">PublicWebSecurityGroup</span> assigned. This will ensure that only the LB can talk to the web EC2 instances.</li>
</ul>
<h3>Outputs</h3>
<ul>
<li>The template outputs the stack access URL. Again, it uses the <span style="font-family: courier new, courier, monospace;">CreateMultipleInstances</span> condition to determine whether the output URL should be based on the load balancer or the <span style="font-family: courier new, courier, monospace;">Web1EC2Instance</span>.</li>
</ul>
<h3>Metadata</h3>
<p>This section contains data used by the CFN Designer tool.</p>
<h2>Sample Deployment Commands</h2>
<p>The following command shows a Production deployment.</p>
<pre class="lang:default decode:true">aws cloudformation deploy --profile aws-training --stack-name MyAppProdStack --parameter-overrides DeploymentType=Production VPC=vpc-0ef286bd199748f2a Subnet1=subnet-05eaf962fd4e0e12c Subnet2=subnet-00077ede2ac0521a6 SSHSecurityGroup=sg-0fa7434cec1fd0b2d KeyPair=C9SSHKeyPair --template-file cfns/Multi_Tier_Stack.json</pre>
<p>And, here&#8217;s a command that shows a Development deployment.</p>
<pre class="lang:default decode:true">aws cloudformation deploy --profile aws-training --stack-name MyAppDevStack --parameter-overrides DeploymentType=Development VPC=vpc-0ef286bd199748f2a Subnet1=subnet-05eaf962fd4e0e12c Subnet2=subnet-00077ede2ac0521a6 SSHSecurityGroup=sg-0fa7434cec1fd0b2d KeyPair=C9SSHKeyPair --template-file cfns/Multi_Tier_Stack.json</pre>
<h2>Conclusion</h2>
<p>Great job in reading along. As you might have already gathered, authoring a good CFN template is no different from writing good code. It needs to have considerations of what you are trying to accomplish, enterprise readiness aspects like security and be cost-efficient. By thinking about these points upfront you can not only design a better template but also avoid common issues and save time in the longer run.</p>
<p>Happy deploying!<br />
&#8211; Nitin</p>
<p><div class="su-note"  style="border-color:#e5d6d4;border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px;"><div class="su-note-inner su-u-clearfix su-u-trim" style="background-color:#fff0ee;border-color:#ffffff;color:#333333;border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px;"></p>
<center>
<h4>Enhance your AWS skills with these hands-on courses for real-world deployments.</h4>
</center>
<p><div class="su-row"> <div class="su-column su-column-size-1-2"><div class="su-column-inner su-u-clearfix su-u-trim"></p>
<p><a href="https://cloudnineapps.com/courses/cloud-computing/aws-cloudformation-deep-dive/"><img class="aligncenter wp-image-3758 size-medium" src="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/courses/Cloud_Computing/AWS_CloudFormation_Deep_Dive/AWS_CloudFormation_Deep_Dive_Logo.png?resize=192%2C108&#038;ssl=1" alt="" width="192" height="108" data-recalc-dims="1" /></a></p>
<center>Learn CloudFormation from concepts to hands-on examples.</center>
<p></div></div> <div class="su-column su-column-size-1-2"><div class="su-column-inner su-u-clearfix su-u-trim"></p>
<p><a href="https://cloudnineapps.com/courses/cloud-computing/aws-advanced-for-developers/"><img class="size-full wp-image-2068 aligncenter" src="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/courses/Cloud_Computing/AWS_Advanced_For_Developers/AWS_Advanced_For_Developers_Logo_small.png?resize=192%2C108&#038;ssl=1" alt="" width="192" height="108" data-recalc-dims="1" /></a></p>
<center>Learn practical application development on AWS.</center>
<p></div></div> </div></div></div></p>
<p>&nbsp;</p>
<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fhow-to-create-a-multi-tier-stack-using-aws-cloudformation%2F&amp;linkname=How%20To%20Create%20A%20Multi-Tier%20Stack%20Using%20AWS%20CloudFormation" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fhow-to-create-a-multi-tier-stack-using-aws-cloudformation%2F&amp;linkname=How%20To%20Create%20A%20Multi-Tier%20Stack%20Using%20AWS%20CloudFormation" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fhow-to-create-a-multi-tier-stack-using-aws-cloudformation%2F&amp;linkname=How%20To%20Create%20A%20Multi-Tier%20Stack%20Using%20AWS%20CloudFormation" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fhow-to-create-a-multi-tier-stack-using-aws-cloudformation%2F&amp;linkname=How%20To%20Create%20A%20Multi-Tier%20Stack%20Using%20AWS%20CloudFormation" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd a2a_counter addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fhow-to-create-a-multi-tier-stack-using-aws-cloudformation%2F&#038;title=How%20To%20Create%20A%20Multi-Tier%20Stack%20Using%20AWS%20CloudFormation" data-a2a-url="https://cloudnineapps.com/blogs/cloud-computing/how-to-create-a-multi-tier-stack-using-aws-cloudformation/" data-a2a-title="How To Create A Multi-Tier Stack Using AWS CloudFormation"></a></p><p>The post <a rel="nofollow" href="https://cloudnineapps.com/blogs/cloud-computing/how-to-create-a-multi-tier-stack-using-aws-cloudformation/">How To Create A Multi-Tier Stack Using AWS CloudFormation</a> appeared first on <a rel="nofollow" href="https://cloudnineapps.com">Cloud Nine Apps</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://cloudnineapps.com/blogs/cloud-computing/how-to-create-a-multi-tier-stack-using-aws-cloudformation/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">4405</post-id>	</item>
		<item>
		<title>How To Troubleshoot AWS CloudFormation Errors</title>
		<link>https://cloudnineapps.com/blogs/cloud-computing/how-to-troubleshoot-aws-cloudformation-errors/</link>
					<comments>https://cloudnineapps.com/blogs/cloud-computing/how-to-troubleshoot-aws-cloudformation-errors/#respond</comments>
		
		<dc:creator><![CDATA[Nitin Patil]]></dc:creator>
		<pubDate>Tue, 17 Dec 2019 11:25:51 +0000</pubDate>
				<category><![CDATA[Cloud Computing]]></category>
		<guid isPermaLink="false">https://cloudnineapps.com/?p=4297</guid>

					<description><![CDATA[<p>How To Troubleshoot AWS CloudFormation Errors? AWS CloudFormation (CFN) helps in automating deployments by delivering Infrastructure as a Code (IaaC). It offers several useful capabilities, like simple templates, support for a wide range of AWS services, dependency management, parallel deployments,&#8230;&#160;<a href="https://cloudnineapps.com/blogs/cloud-computing/how-to-troubleshoot-aws-cloudformation-errors/" class="more-link">Read More</a></p>
<p>The post <a rel="nofollow" href="https://cloudnineapps.com/blogs/cloud-computing/how-to-troubleshoot-aws-cloudformation-errors/">How To Troubleshoot AWS CloudFormation Errors</a> appeared first on <a rel="nofollow" href="https://cloudnineapps.com">Cloud Nine Apps</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h1>How To Troubleshoot AWS CloudFormation Errors?</h1>
<p>AWS CloudFormation (CFN) helps in automating deployments by delivering Infrastructure as a Code (IaaC). It offers several useful capabilities, like simple templates, support for a wide range of AWS services, dependency management, parallel deployments, and so on. To use CloudFormation, you create CFN templates either from scratch or from samples. You can also use tools like the CloudFormation Designer to author the CFN templates. However, similarly to coding, you will run into errors with CFN as well. In this post, we will cover the two prominent types of CFN errors and how to troubleshoot these.</p>
<h2>Types of CloudFormation Errors</h2>
<p>There are two types of CFN errors.</p>
<ol>
<li><strong>Syntax Errors</strong>: A CFN template is a text document in either JSON or YAML format. The syntax errors in the CFN template lead to this error. For example, a missing comma or brace in JSON, an incorrect indentation in YAML, and so on. Such a template is not even deployed as the CloudFormation Console or the CLI will fail upon detecting the error.</li>
<li><strong>Semantic Errors</strong>: These occur at deployment time typically due to coding or an infrastructure issue. For example, an incorrectly specified resource property name, trying to create a duplicate resource, and so on.</li>
</ol>
<h2>How To Troubleshoot CloudFormation Syntax Errors?</h2>
<p>Let&#8217;s take an example here. The following screenshot shows a CFN template snippet in JSON format.</p>
<p><a href="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Syntax_Error_Missing_Brace.png?ssl=1"><img class="alignnone wp-image-4301 size-large" src="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Syntax_Error_Missing_Brace.png?resize=640%2C376&#038;ssl=1" alt="" width="640" height="376" srcset="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Syntax_Error_Missing_Brace.png?resize=1024%2C602&amp;ssl=1 1024w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Syntax_Error_Missing_Brace.png?resize=300%2C176&amp;ssl=1 300w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Syntax_Error_Missing_Brace.png?resize=768%2C451&amp;ssl=1 768w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Syntax_Error_Missing_Brace.png?resize=320%2C188&amp;ssl=1 320w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Syntax_Error_Missing_Brace.png?resize=640%2C376&amp;ssl=1 640w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Syntax_Error_Missing_Brace.png?resize=360%2C212&amp;ssl=1 360w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Syntax_Error_Missing_Brace.png?resize=720%2C423&amp;ssl=1 720w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Syntax_Error_Missing_Brace.png?resize=1080%2C635&amp;ssl=1 1080w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Syntax_Error_Missing_Brace.png?resize=800%2C470&amp;ssl=1 800w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Syntax_Error_Missing_Brace.png?w=1247&amp;ssl=1 1247w" sizes="(max-width: 640px) 100vw, 640px" data-recalc-dims="1" /></a></p>
<p>As you can see, the curly brace for the <span style="font-family: courier new, courier, monospace;">PolicyDocument</span> property is missing. When we try to deploy this CFN template, we will see an error like the one shown below.</p>
<p><a href="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Syntax_Error_Missing_Brace_CLI_Output.png?ssl=1"><img class="alignnone wp-image-4300 size-large" src="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Syntax_Error_Missing_Brace_CLI_Output.png?resize=640%2C200&#038;ssl=1" alt="" width="640" height="200" srcset="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Syntax_Error_Missing_Brace_CLI_Output.png?resize=1024%2C320&amp;ssl=1 1024w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Syntax_Error_Missing_Brace_CLI_Output.png?resize=300%2C94&amp;ssl=1 300w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Syntax_Error_Missing_Brace_CLI_Output.png?resize=768%2C240&amp;ssl=1 768w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Syntax_Error_Missing_Brace_CLI_Output.png?resize=320%2C100&amp;ssl=1 320w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Syntax_Error_Missing_Brace_CLI_Output.png?resize=640%2C200&amp;ssl=1 640w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Syntax_Error_Missing_Brace_CLI_Output.png?resize=360%2C113&amp;ssl=1 360w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Syntax_Error_Missing_Brace_CLI_Output.png?resize=720%2C225&amp;ssl=1 720w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Syntax_Error_Missing_Brace_CLI_Output.png?resize=1080%2C338&amp;ssl=1 1080w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Syntax_Error_Missing_Brace_CLI_Output.png?resize=800%2C250&amp;ssl=1 800w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Syntax_Error_Missing_Brace_CLI_Output.png?w=1266&amp;ssl=1 1266w" sizes="(max-width: 640px) 100vw, 640px" data-recalc-dims="1" /></a></p>
<p>Here the JSON parser has detected a missing comma or a curly brace. After you add the missing brace, the error will be resolved. Errors like these are quite common during development. Here are some tips on how to resolve or minimize the occurrence of such errors.</p>
<ul>
<li>Check if your text editor supports block matching capabilities, like the powerful <a href="https://www.vim.org/" target="_blank" rel="nofollow noopener noreferrer">VI editor</a>. This can be used to find the matching brace, and if you find that it is not on the expected element you have found the problem area. Then you can keep drilling down till you find the problem. As a general practice, it is also a good idea to always specify the closing brace when opening a brace so that you do not miss it. This can really come in handy for large templates.</li>
<li>You can also use a JSON validator or beautifier. There are several available online. While in most cases the validator may not reveal any more useful information than what the CFN CLI output shows, the beautifier may be a bit helpful to visually inspect the template for any anomalies.</li>
</ul>
<h2>How To Troubleshoot CloudFormation Semantic Errors?</h2>
<p>The semantic errors can range from simple things like incorrect property names, missing resource names to infrastructure-related errors, such as duplicate infrastructure resource name. And, as we discussed earlier, these occur at the deployment time. So, it may increase your end-to-end resolution time. Let&#8217;s take the example wherein we are trying to deploy an S3 bucket using a CFN template but a bucket with the specified name already exists. The following screenshot shows the CFN CLI output.</p>
<p><a href="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Semantic_Error_Existing_Resource_CLI_Output.png?ssl=1"><img class="alignnone wp-image-4303 size-large" src="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Semantic_Error_Existing_Resource_CLI_Output.png?resize=640%2C170&#038;ssl=1" alt="" width="640" height="170" srcset="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Semantic_Error_Existing_Resource_CLI_Output.png?resize=1024%2C272&amp;ssl=1 1024w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Semantic_Error_Existing_Resource_CLI_Output.png?resize=300%2C80&amp;ssl=1 300w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Semantic_Error_Existing_Resource_CLI_Output.png?resize=768%2C204&amp;ssl=1 768w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Semantic_Error_Existing_Resource_CLI_Output.png?resize=320%2C85&amp;ssl=1 320w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Semantic_Error_Existing_Resource_CLI_Output.png?resize=640%2C170&amp;ssl=1 640w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Semantic_Error_Existing_Resource_CLI_Output.png?resize=360%2C96&amp;ssl=1 360w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Semantic_Error_Existing_Resource_CLI_Output.png?resize=720%2C191&amp;ssl=1 720w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Semantic_Error_Existing_Resource_CLI_Output.png?resize=1080%2C287&amp;ssl=1 1080w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Semantic_Error_Existing_Resource_CLI_Output.png?resize=800%2C213&amp;ssl=1 800w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Semantic_Error_Existing_Resource_CLI_Output.png?w=1264&amp;ssl=1 1264w" sizes="(max-width: 640px) 100vw, 640px" data-recalc-dims="1" /></a></p>
<p>As you can see, the CLI execution failed. However, unlike the syntax error, the details are not available in this output. So, to troubleshoot further, you can either go to the CloudFormation Console or run the command shown in the above output.</p>
<p><span style="font-family: courier new, courier, monospace;">aws cloudformation describe-stack-events &#8211;stack-name c9apps-demo-bucket1</span></p>
<p>This will show the stack events in reverse chronological order (most recent event first). Scroll through the list till you find the error cause as shown below.</p>
<p><a href="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Semantic_Error_Existing_Resource_CLI_Describe_Events.png?ssl=1"><img class="alignnone size-large wp-image-4304" src="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Semantic_Error_Existing_Resource_CLI_Describe_Events.png?resize=640%2C389&#038;ssl=1" alt="" width="640" height="389" srcset="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Semantic_Error_Existing_Resource_CLI_Describe_Events.png?resize=1024%2C623&amp;ssl=1 1024w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Semantic_Error_Existing_Resource_CLI_Describe_Events.png?resize=300%2C182&amp;ssl=1 300w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Semantic_Error_Existing_Resource_CLI_Describe_Events.png?resize=768%2C467&amp;ssl=1 768w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Semantic_Error_Existing_Resource_CLI_Describe_Events.png?resize=320%2C195&amp;ssl=1 320w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Semantic_Error_Existing_Resource_CLI_Describe_Events.png?resize=640%2C389&amp;ssl=1 640w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Semantic_Error_Existing_Resource_CLI_Describe_Events.png?resize=360%2C219&amp;ssl=1 360w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Semantic_Error_Existing_Resource_CLI_Describe_Events.png?resize=720%2C438&amp;ssl=1 720w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Semantic_Error_Existing_Resource_CLI_Describe_Events.png?resize=1080%2C657&amp;ssl=1 1080w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Semantic_Error_Existing_Resource_CLI_Describe_Events.png?resize=800%2C487&amp;ssl=1 800w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Semantic_Error_Existing_Resource_CLI_Describe_Events.png?w=1266&amp;ssl=1 1266w" sizes="(max-width: 640px) 100vw, 640px" data-recalc-dims="1" /></a></p>
<p>It shows that a bucket named <span style="font-family: courier new, courier, monospace;">c9apps-demo-bucket</span> (which was the bucket name we specified when deploying the template) already exists in another stack. This approach can be particularly useful for DevOps pipelines to retrieve the error information.</p>
<p>The other option is to go to the CloudFormation Console and look into the stack events for the error cause as shown below.</p>
<p><a href="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Semantic_Error_Existing_Resource_Console_Output.png?ssl=1"><img class="alignnone size-large wp-image-4302" src="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_CFN_Errors/CFN_Semantic_Error_Existing_Resource_Console_Output.png?resize=640%2C378&#038;ssl=1" alt="" width="640" height="378" data-recalc-dims="1" /></a></p>
<p>As we can see, the console shows the same information.</p>
<p>While semantic errors is a broader category and it is difficult to have a silver bullet solution for every scenario, here are some general tips.</p>
<ul>
<li>Use the <a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html" target="_blank" rel="nofollow noopener noreferrer">AWS Resource and Property Types Reference</a> document to check the resources types and properties.</li>
<li>Use unique resource identifier names in the CFN templates. In general, giving names based on purpose is a good idea. For example, instead of calling it <span style="font-family: courier new, courier, monospace;">EC2Instance1</span>, a better name would be <span style="font-family: courier new, courier, monospace;">WebTierInstance1</span>.</li>
<li>CloudFormation offers several <a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html" target="_blank" rel="nofollow noopener noreferrer">Intrinsic Functions</a> for common computing needs. Leverage from these to make more meaningful and unique resource names. For example, the <span style="font-family: courier new, courier, monospace;">Fn::Join</span> Intrinsic Function can be used to combine a list of strings.</li>
<li>Leverage from the lifecycle for choosing the resource names. For example, resources that are global in nature (such as IAM role) may not have the stack name as part of their names. Whereas, resources that are meant for a specific stack only can use the stack name to make their names unique.</li>
</ul>
<p>Troubleshooting CFN errors takes some practice. Also, at times the error messages may not be easy to understand. So, it is a good idea to familiarize yourself with these techniques so that you are better prepared when the issues occur.</p>
<p>Be a smart troubleshooter!<br />
&#8211; Nitin</p>
<p><em>If you liked this post, you will find my <a href="https://cloudnineapps.com/courses/cloud-computing/aws-cloudformation-deep-dive/" target="_blank" rel="noopener noreferrer">AWS CloudFormation Deep Dive</a> course helpful that focuses on many such best practices, techniques and hands-on examples to use CloudFormation in real-world deployments.<br />
</em></p>
<p>&nbsp;</p>
<p><div class="su-note"  style="border-color:#e5d6d4;border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px;"><div class="su-note-inner su-u-clearfix su-u-trim" style="background-color:#fff0ee;border-color:#ffffff;color:#333333;border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px;"></p>
<center>
<h4>Enhance your AWS skills with these hands-on courses for real-world deployments.</h4>
</center>
<p><div class="su-row"> <div class="su-column su-column-size-1-2"><div class="su-column-inner su-u-clearfix su-u-trim"></p>
<p><a href="https://cloudnineapps.com/courses/cloud-computing/aws-cloudformation-deep-dive/"><img class="aligncenter wp-image-3758 size-medium" src="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/courses/Cloud_Computing/AWS_CloudFormation_Deep_Dive/AWS_CloudFormation_Deep_Dive_Logo.png?resize=192%2C108&#038;ssl=1" alt="" width="192" height="108" data-recalc-dims="1" /></a></p>
<center>Learn CloudFormation from concepts to hands-on examples.</center>
<p></div></div> <div class="su-column su-column-size-1-2"><div class="su-column-inner su-u-clearfix su-u-trim"></p>
<p><a href="https://cloudnineapps.com/courses/cloud-computing/aws-advanced-for-developers/"><img class="size-full wp-image-2068 aligncenter" src="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/courses/Cloud_Computing/AWS_Advanced_For_Developers/AWS_Advanced_For_Developers_Logo_small.png?resize=192%2C108&#038;ssl=1" alt="" width="192" height="108" data-recalc-dims="1" /></a></p>
<center>Learn practical application development on AWS.</center>
<p></div></div> </div></div></div></p>
<p>&nbsp;</p>
<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fhow-to-troubleshoot-aws-cloudformation-errors%2F&amp;linkname=How%20To%20Troubleshoot%20AWS%20CloudFormation%20Errors" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fhow-to-troubleshoot-aws-cloudformation-errors%2F&amp;linkname=How%20To%20Troubleshoot%20AWS%20CloudFormation%20Errors" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fhow-to-troubleshoot-aws-cloudformation-errors%2F&amp;linkname=How%20To%20Troubleshoot%20AWS%20CloudFormation%20Errors" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fhow-to-troubleshoot-aws-cloudformation-errors%2F&amp;linkname=How%20To%20Troubleshoot%20AWS%20CloudFormation%20Errors" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd a2a_counter addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fhow-to-troubleshoot-aws-cloudformation-errors%2F&#038;title=How%20To%20Troubleshoot%20AWS%20CloudFormation%20Errors" data-a2a-url="https://cloudnineapps.com/blogs/cloud-computing/how-to-troubleshoot-aws-cloudformation-errors/" data-a2a-title="How To Troubleshoot AWS CloudFormation Errors"></a></p><p>The post <a rel="nofollow" href="https://cloudnineapps.com/blogs/cloud-computing/how-to-troubleshoot-aws-cloudformation-errors/">How To Troubleshoot AWS CloudFormation Errors</a> appeared first on <a rel="nofollow" href="https://cloudnineapps.com">Cloud Nine Apps</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://cloudnineapps.com/blogs/cloud-computing/how-to-troubleshoot-aws-cloudformation-errors/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">4297</post-id>	</item>
		<item>
		<title>How To Create Dynamic Condition Expressions In AWS CloudFormation Using Macros</title>
		<link>https://cloudnineapps.com/blogs/cloud-computing/how-to-create-dynamic-condition-expressions-in-aws-cloudformation-using-macros/</link>
					<comments>https://cloudnineapps.com/blogs/cloud-computing/how-to-create-dynamic-condition-expressions-in-aws-cloudformation-using-macros/#respond</comments>
		
		<dc:creator><![CDATA[Nitin Patil]]></dc:creator>
		<pubDate>Thu, 05 Dec 2019 12:13:12 +0000</pubDate>
				<category><![CDATA[Cloud Computing]]></category>
		<guid isPermaLink="false">https://cloudnineapps.com/?p=4338</guid>

					<description><![CDATA[<p>How To Create Dynamic Condition Expressions In AWS CloudFormation Using Macros? AWS CloudFormation (CFN) conditions are quite useful for purposes like conditionally create resources, conditionally set the resource properties, and so on. However, when you start getting into some advanced&#8230;&#160;<a href="https://cloudnineapps.com/blogs/cloud-computing/how-to-create-dynamic-condition-expressions-in-aws-cloudformation-using-macros/" class="more-link">Read More</a></p>
<p>The post <a rel="nofollow" href="https://cloudnineapps.com/blogs/cloud-computing/how-to-create-dynamic-condition-expressions-in-aws-cloudformation-using-macros/">How To Create Dynamic Condition Expressions In AWS CloudFormation Using Macros</a> appeared first on <a rel="nofollow" href="https://cloudnineapps.com">Cloud Nine Apps</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h1>How To Create Dynamic Condition Expressions In AWS CloudFormation Using Macros?</h1>
<p>AWS CloudFormation (CFN) conditions are quite useful for purposes like conditionally create resources, conditionally set the resource properties, and so on. However, when you start getting into some advanced scenarios, these may become a bit limited. For example, checking for the existence of a resource so that you create it only once. How do you handle such scenarios? Is there any way you can do this via CFN as opposed to using some alternatives? That is precisely the purpose of this article.</p>
<p>Note that this is an advanced CFN topic. If you are new to CFN, please check out the <a href="https://cloudnineapps.com/blogs/cloud-computing/aws-cloudformation-an-architects-best-friend/" target="_blank" rel="noopener noreferrer">AWS CloudFormation &#8211; An Architect&#8217;s Best Friend</a> to understand the basics first.</p>
<h2>What Does Creating A Dynamic Condition Expression Mean?</h2>
<p>Simply put, it means creating the expression text dynamically at the deployment time. Typically, the condition expression is <span style="text-decoration: underline;">static</span>. For example, take a look at the condition below that will evaluate to true if the <span style="font-family: courier new, courier, monospace;">CreateGlobalResourcesParam</span> parameter is set to <span style="font-family: courier new, courier, monospace;">&#8220;true&#8221;</span>.</p>
<pre class="lang:default decode:true">  "CreateGlobalResources": {"Fn::Equals", ["true", {"Ref": "CreateGlobalResourcesParam"}]}</pre>
<p>When creating a Dynamic Condition Expression, the expression text is prepared at the deployment time.</p>
<pre class="lang:default decode:true">"CreateGlobalResources": &lt;content to prepare the expression text dynamically&gt;</pre>
<h2>What Is The Need To Create A Dynamic Condition Expression?</h2>
<p>To understand the need, let&#8217;s take a simple use case. Let&#8217;s say you have a CFN template that creates a serverless stack. It comprises a lambda and associated resources. Since the user base is spread across the globe, the plan is to create a stack per target region. For this discussion, let&#8217;s use <span style="font-family: courier new, courier, monospace;">us-east-1</span> and <span style="font-family: courier new, courier, monospace;">us-west-1</span> AWS regions with <span style="font-family: courier new, courier, monospace;">us-east-1</span> being the primary region.</p>
<p>So far so good. Now, we know that lambda requires an execution IAM role so that it has access to the required AWS resources. And, there are going to be two lambda deployments (one per region). So, we have two options &#8211; either create a lambda role per stack or create a single IAM role (say, in the primary stack) that will be used by all subsequent stacks. Both options have their own merits. The former offers more autonomy to each stack, whereas the second option leverages from the lifecycle of resources and minimizes the sprawl of roles that serve the same purpose. Another advantage of the second option is if there were updates to the role, you only need to update the primary stack and all stacks will automatically get the updates, thus reducing the end-to-end rollout team. Also, there are <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_iam-limits.html" target="_blank" rel="noopener noreferrer nofollow">limits to the number of IAM roles</a> you can create. Although, you may be able to request an increase. This is just one scenario. But, there could be similar other use cases where you are trying to reuse a global resource across stacks.</p>
<p>So, for this discussion let&#8217;s say that we do want to create the IAM role only once. Now, let&#8217;s talk about how to achieve this by creating a Dynamic Condition Expression.</p>
<h2>Using Macro To Create A Dynamic Condition Expression</h2>
<p>CFN offers a powerful capability called <strong>Macro</strong>. If you have ever programmed in a language like C/C++ (or another language that supports pre-processors), you may be already familiar with the use of macros. Essentially, a CFN Macro lets you execute certain logic to modify either the content of the template or a snippet within the template. All macros are evaluated <span style="text-decoration: underline;">before</span> executing the CFN template. So, these are perfect to inject the condition expression dynamically. The following screenshot demonstrates this.</p>
<p><a href="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Dynamic_Condition_Expression_Sample.png?ssl=1"><img class="alignnone size-large wp-image-4379" src="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Dynamic_Condition_Expression_Sample.png?resize=640%2C164&#038;ssl=1" alt="" width="640" height="164" srcset="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Dynamic_Condition_Expression_Sample.png?resize=1024%2C263&amp;ssl=1 1024w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Dynamic_Condition_Expression_Sample.png?resize=300%2C77&amp;ssl=1 300w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Dynamic_Condition_Expression_Sample.png?resize=768%2C197&amp;ssl=1 768w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Dynamic_Condition_Expression_Sample.png?resize=320%2C82&amp;ssl=1 320w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Dynamic_Condition_Expression_Sample.png?resize=640%2C164&amp;ssl=1 640w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Dynamic_Condition_Expression_Sample.png?resize=360%2C92&amp;ssl=1 360w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Dynamic_Condition_Expression_Sample.png?resize=720%2C185&amp;ssl=1 720w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Dynamic_Condition_Expression_Sample.png?resize=1080%2C277&amp;ssl=1 1080w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Dynamic_Condition_Expression_Sample.png?resize=800%2C205&amp;ssl=1 800w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Dynamic_Condition_Expression_Sample.png?resize=1280%2C328&amp;ssl=1 1280w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Dynamic_Condition_Expression_Sample.png?w=1294&amp;ssl=1 1294w" sizes="(max-width: 640px) 100vw, 640px" data-recalc-dims="1" /></a></p>
<p>Let&#8217;s understand this better.</p>
<ul>
<li>In the <strong>Conditions</strong> block, we are defining a condition named <span style="font-family: courier new, courier, monospace;">CreateGlobalResources</span>. It should be set to <span style="font-family: courier new, courier, monospace;">true</span> if the global resources should be created. Otherwise, it should be set to <span style="font-family: courier new, courier, monospace;">false</span>.</li>
<li>It is using the <span style="font-family: courier new, courier, monospace;">Fn::Transform</span> intrinsic function to invoke the <span style="font-family: courier new, courier, monospace;">ResourceHelper</span> macro with 2 parameters &#8211; <span style="font-family: courier new, courier, monospace;">Operation</span> and <span style="font-family: courier new, courier, monospace;">RoleName</span>. We will see the details of the macro later in this post. The <span style="font-family: courier new, courier, monospace;">Operation</span> parameter specifies the operation to perform (in this case, <span style="font-family: courier new, courier, monospace;">roleExists</span>, which will check for the existence of the specified role). The <span style="font-family: courier new, courier, monospace;">RoleName</span> parameter specifies the name of the role to check.</li>
<li>Here, the macro is expected to return the string <span style="font-family: courier new, courier, monospace;">&#8220;true&#8221;</span> only if the role exists. Otherwise, it should return the string <span style="font-family: courier new, courier, monospace;">&#8220;false&#8221;</span>. This value is then compared with <span style="font-family: courier new, courier, monospace;">&#8220;false&#8221;</span> using the <span style="font-family: courier new, courier, monospace;">Fn::Equals</span> intrinsic function.</li>
<li>This condition will be then used later in the template to conditionally create the <span style="font-family: courier new, courier, monospace;">LambdaFunctionRole</span> role as shown below.<br />
<a href="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Condition_Usage_Example.png?ssl=1"><img class="alignnone size-large wp-image-4352" src="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Condition_Usage_Example.png?resize=640%2C338&#038;ssl=1" alt="" width="640" height="338" srcset="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Condition_Usage_Example.png?resize=1024%2C541&amp;ssl=1 1024w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Condition_Usage_Example.png?resize=300%2C158&amp;ssl=1 300w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Condition_Usage_Example.png?resize=768%2C406&amp;ssl=1 768w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Condition_Usage_Example.png?resize=320%2C169&amp;ssl=1 320w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Condition_Usage_Example.png?resize=640%2C338&amp;ssl=1 640w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Condition_Usage_Example.png?resize=360%2C190&amp;ssl=1 360w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Condition_Usage_Example.png?resize=720%2C380&amp;ssl=1 720w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Condition_Usage_Example.png?resize=1080%2C571&amp;ssl=1 1080w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Condition_Usage_Example.png?resize=800%2C423&amp;ssl=1 800w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Condition_Usage_Example.png?resize=1280%2C676&amp;ssl=1 1280w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Condition_Usage_Example.png?w=1310&amp;ssl=1 1310w" sizes="(max-width: 640px) 100vw, 640px" data-recalc-dims="1" /></a></li>
</ul>
<p>The idea here is when the primary stack is deployed in <span style="font-family: courier new, courier, monospace;">us-east-1</span>, the macro will return <span style="font-family: courier new, courier, monospace;">&#8220;false&#8221;</span> as the <span style="font-family: courier new, courier, monospace;">LambdaFunctionRole</span> role does not exist yet. Hence, the <span style="font-family: courier new, courier, monospace;">CreateGlobalResources</span> condition will be set to <span style="font-family: courier new, courier, monospace;">true</span> and the <span style="font-family: courier new, courier, monospace;">LambdaFunctionRole</span> will be created. When the stack is deployed in <span style="font-family: courier new, courier, monospace;">us-west-1</span>, the macro will return <span style="font-family: courier new, courier, monospace;">&#8220;true&#8221;</span> and the <span style="font-family: courier new, courier, monospace;">CreateGlobalResources</span> condition will be set to <span style="font-family: courier new, courier, monospace;">false</span>. Hence, the role will not be created again.</p>
<h2>Let&#8217;s See The Macro Code</h2>
<p>Now that we understand how the Dynamic Condition Expression is created, let&#8217;s take a look at the macro code.</p>
<pre class="lang:default decode:true">{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Description": "A stack to provide utility methods for resources.",
  "Parameters": {
    "CreateLambdaRole": {
      "Description": "Whether to create the lambda role.",
      "Type": "String",
      "AllowedValues": ["true", "false"],
      "Default": "true"
    }
  },
  "Conditions": {
    "CreateGlobalResources": {"Fn::Equals": ["true", {"Ref": "CreateLambdaRole"}]}
  },
  "Resources": {
    "ResourceHelper": {
      "Type": "AWS::CloudFormation::Macro",
      "Properties": {
        "Name": {"Ref": "AWS::StackName"},
        "Description": "A macro to provide utility methods for resources.",
        "FunctionName": {"Fn::GetAtt": ["ResourceHelperLambda", "Arn"]}
      }
    },
    "ResourceHelperLambda": {
      "Type": "AWS::Lambda::Function",
      "Properties": {
        "FunctionName": "ResourceHelperLambda",
        "Handler": "index.handler",
        "Runtime": "nodejs8.10",
        "Role": {"Fn::Join": ["", ["arn:aws:iam::", {"Ref": "AWS::AccountId"}, ":role/ResourceHelperLambdaRole"]]},
        "MemorySize": "128",
        "Timeout": "30",
        "Code": {
          "ZipFile": {"Fn::Join": ["", [
            "const AWS = require('aws-sdk');\n",
            "AWS.config.update({region: '", {"Ref": "AWS::Region"}, "'});\n",
            "const iam = new AWS.IAM();\n",
            "\n",
            "exports.handler = (event, context, callback) =&gt; {\n",
            "  console.log('handler(): event: ' + JSON.stringify(event));\n",
            "  const params = event.params;\n",
            "  const op = params.Operation;\n",
			" const roleName = params.RoleName;\n",
            "  if (op == 'roleExists') {\n",
            "    var request = {\n",
            "      RoleName: roleName\n",
            "    };\n",
            "    iam.waitFor('roleExists', request, function(err, data) {\n",
            "      if (err) {\n",
            "        // Role does not exist\n",
            "        handleResponse(null, 'true');\n",
            "      }\n",
            "      else if (data.Role) {\n",
            "        // Role exists\n",
            "        handleResponse(null, 'false');\n",
            "      }\n",
            "      else {\n",
            "        handleResponse(new Error(`Could not get information about role '${params.RoleName}'.`), null);\n",
            "      }\n",
            "    });\n",
            "  }\n",
            "  else {\n",
            "    handleResponse(new Error(`Unsupported operation '${Operation}'.`), null);\n",
            "  }\n",
            "  const handleResponse = function(err, data) {\n",
            "    var response = {\n",
            "      status: 'SUCCESS',\n",
            "      requestId: event.requestId,\n",
            "    };\n",
            "    if (err) {\n",
            "      console.log('handleResponse(): ' + err);\n",
            "      response.status = 'FAILURE';\n",
            "    }\n",
            "    else {\n",
            "      response.fragment = data;\n",
            "    }\n",
            "    console.log('handleResponse(): response: ' + JSON.stringify(response));\n",
            "    callback(null, response);\n",
            "  };\n",
            "}\n"
          ]]}
        }
      }
    },
    "ResourceHelperLambdaRole": {
      "Type": "AWS::IAM::Role",
      "Condition": "CreateGlobalResources",
      "Properties": {
        "RoleName": "ResourceHelperLambdaRole",
        "AssumeRolePolicyDocument": {
          "Version": "2012-10-17",
          "Statement": [{
            "Effect": "Allow",
            "Principal": {
              "Service": "lambda.amazonaws.com"
            },
            "Action": "sts:AssumeRole"
          }]
        },
        "ManagedPolicyArns": [
          "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole",
          "arn:aws:iam::aws:policy/IAMReadOnlyAccess"
        ]
      }
    },
    "ResourceHelperLambdaLogGroup": {
      "Type": "AWS::Logs::LogGroup",
      "Properties": {
        "LogGroupName": {"Fn::Join": ["", ["/aws/lambda/", {"Ref": "ResourceHelperLambda"}]]},
        "RetentionInDays": 1
      }
    }
  }
}

</pre>
<p>As we know, the purpose of this macro is to prepare the Dynamic Condition Expression text with value as either <span style="font-family: courier new, courier, monospace;">&#8220;true&#8221;</span> (if the role exists) or <span style="font-family: courier new, courier, monospace;">&#8220;false&#8221;</span>. A macro is essentially a lambda-based stack that exists in the same region as the consuming stack. Here, I am using Node.js for implementation. If you are not familiar with it, do not worry. I will explain the important aspects below.</p>
<ul>
<li>The macro CFN template takes a single parameter &#8211; <span style="font-family: courier new, courier, monospace;">CreateLambdaRole</span>. It is referred by the <span style="font-family: courier new, courier, monospace;">CreateGlobalResources</span> condition that is used to conditionally create the IAM role required for the macro lambda. Do not confuse this with the use case we saw earlier. The condition here is strictly for the macro lambda role only. Can you guess why? Perhaps you got it. Since there are 2 AWS regions in our sample deployment, we will have 2 deployments of the macro stack as well. But, we would create the IAM role for the macro lambda only once and use it for both the stacks. So, when the macro stack is created in the primary region (<span style="font-family: courier new, courier, monospace;">us-east-1</span>), the <span style="font-family: courier new, courier, monospace;">CreateLambdaRole</span> parameter will be set to <span style="font-family: courier new, courier, monospace;">&#8220;true&#8221;</span> and the macro lambda role will be created. And, vice-versa for <span style="font-family: courier new, courier, monospace;">us-west-1</span>.</li>
<li>The first resource is the <span style="font-family: courier new, courier, monospace;">ResourceHelper</span> macro itself.</li>
<li>The next resource is the <span style="font-family: courier new, courier, monospace;">ResourceHelperLambda</span> that provides macro implementation.
<ul>
<li>In its <span style="font-family: courier new, courier, monospace;">Code</span> block, the AWS SDK is initialized first.</li>
<li>Next in the <span style="font-family: courier new, courier, monospace;">handler</span> function, we are first extracting the <span style="font-family: courier new, courier, monospace;">Operation</span> and <span style="font-family: courier new, courier, monospace;">RoleName</span> parameters. Apart from these parameters, the macro also receives other request data in a well-defined format, such as the <span style="font-family: courier new, courier, monospace;">requestId</span>, which is a unique identifier for a given macro call. The following screenshot shows a sample macro request.<br />
<a href="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Macro_Sample_Request.png?ssl=1"><img class="alignnone wp-image-4384 size-medium" src="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Macro_Sample_Request.png?resize=300%2C145&#038;ssl=1" alt="" width="300" height="145" srcset="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Macro_Sample_Request.png?resize=300%2C145&amp;ssl=1 300w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Macro_Sample_Request.png?resize=768%2C371&amp;ssl=1 768w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Macro_Sample_Request.png?resize=320%2C155&amp;ssl=1 320w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Macro_Sample_Request.png?resize=640%2C309&amp;ssl=1 640w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Macro_Sample_Request.png?resize=360%2C174&amp;ssl=1 360w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Macro_Sample_Request.png?resize=720%2C348&amp;ssl=1 720w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Macro_Sample_Request.png?resize=800%2C386&amp;ssl=1 800w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Macro_Sample_Request.png?w=816&amp;ssl=1 816w" sizes="(max-width: 300px) 100vw, 300px" data-recalc-dims="1" /></a></li>
<li>This is followed by a check to confirm if the request operation is <span style="font-family: courier new, courier, monospace;">roleExists</span>. If so, an IAM SDK call is issued to check whether the supplied role already exists.</li>
<li>If the role exists, a string with value <span style="font-family: courier new, courier, monospace;">&#8216;true&#8217;</span> is returned. Otherwise, <span style="font-family: courier new, courier, monospace;">&#8216;false&#8217;</span> is returned. This string output is then used to prepare the lambda response in a well-defined format, which includes additional fields, such as <span style="font-family: courier new, courier, monospace;">status</span>. The following screenshot shows a sample macro response. The content of the fragment field is our Dynamic Condition Expression text.<br />
<a href="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Macro_Sample_Response.png?ssl=1"><img class="alignnone wp-image-4382 size-medium" src="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Macro_Sample_Response.png?resize=300%2C62&#038;ssl=1" alt="" width="300" height="62" srcset="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Macro_Sample_Response.png?resize=300%2C62&amp;ssl=1 300w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Macro_Sample_Response.png?resize=768%2C159&amp;ssl=1 768w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Macro_Sample_Response.png?resize=320%2C66&amp;ssl=1 320w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Macro_Sample_Response.png?resize=640%2C132&amp;ssl=1 640w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Macro_Sample_Response.png?resize=360%2C74&amp;ssl=1 360w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Macro_Sample_Response.png?resize=720%2C149&amp;ssl=1 720w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Macro_Sample_Response.png?resize=800%2C165&amp;ssl=1 800w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Create_Dynamic_Expressions_In_AWS_CloudFormation_Using_Macros/Macro_Sample_Response.png?w=822&amp;ssl=1 822w" sizes="(max-width: 300px) 100vw, 300px" data-recalc-dims="1" /></a></li>
<li>The <span style="font-family: courier new, courier, monospace;">ResourceHelperLambdaRole</span> is the IAM role used by the macro lambda.</li>
<li>Finally, the <span style="font-family: courier new, courier, monospace;">ResourceHelperLambdaLogGroup</span> is the log group used by the macro lambda.</li>
</ul>
</li>
</ul>
<p>In this article, we saw how to use macros to create CFN condition expressions dynamically. This capability can be extremely useful, especially if you are trying to avoid splitting provisioning logic in multiple places, such as some in CFN and some via scripts. If you have multiple such common methods, you could create one or more reusable macros that can be used by multiple stacks thus increasing the reusability. So, next time you have a situation where you would want the CFN conditions to be dynamic, you may want to consider creating Dynamic Condition Expressions using macros.</p>
<p>Happy coding!<br />
&#8211; Nitin</p>
<p><em>If you liked this post, you will find my <a href="https://cloudnineapps.com/courses/cloud-computing/aws-cloudformation-deep-dive/" target="_blank" rel="noopener noreferrer">AWS CloudFormation Deep Dive</a> course useful that focuses on many such best practices, techniques and hands-on examples to use CloudFormation in real-world deployments.<br />
</em></p>
<p>&nbsp;</p>
<p><div class="su-note"  style="border-color:#e5d6d4;border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px;"><div class="su-note-inner su-u-clearfix su-u-trim" style="background-color:#fff0ee;border-color:#ffffff;color:#333333;border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px;"></p>
<center>
<h4>Enhance your AWS skills with these hands-on courses for real-world deployments.</h4>
</center>
<p><div class="su-row"> <div class="su-column su-column-size-1-2"><div class="su-column-inner su-u-clearfix su-u-trim"></p>
<p><a href="https://cloudnineapps.com/courses/cloud-computing/aws-cloudformation-deep-dive/"><img class="aligncenter wp-image-3758 size-medium" src="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/courses/Cloud_Computing/AWS_CloudFormation_Deep_Dive/AWS_CloudFormation_Deep_Dive_Logo.png?resize=192%2C108&#038;ssl=1" alt="" width="192" height="108" data-recalc-dims="1" /></a></p>
<center>Learn CloudFormation from concepts to hands-on examples.</center>
<p></div></div> <div class="su-column su-column-size-1-2"><div class="su-column-inner su-u-clearfix su-u-trim"></p>
<p><a href="https://cloudnineapps.com/courses/cloud-computing/aws-advanced-for-developers/"><img class="size-full wp-image-2068 aligncenter" src="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/courses/Cloud_Computing/AWS_Advanced_For_Developers/AWS_Advanced_For_Developers_Logo_small.png?resize=192%2C108&#038;ssl=1" alt="" width="192" height="108" data-recalc-dims="1" /></a></p>
<center>Learn practical application development on AWS.</center>
<p></div></div> </div></div></div></p>
<p>&nbsp;</p>
<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fhow-to-create-dynamic-condition-expressions-in-aws-cloudformation-using-macros%2F&amp;linkname=How%20To%20Create%20Dynamic%20Condition%20Expressions%20In%20AWS%20CloudFormation%20Using%20Macros" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fhow-to-create-dynamic-condition-expressions-in-aws-cloudformation-using-macros%2F&amp;linkname=How%20To%20Create%20Dynamic%20Condition%20Expressions%20In%20AWS%20CloudFormation%20Using%20Macros" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fhow-to-create-dynamic-condition-expressions-in-aws-cloudformation-using-macros%2F&amp;linkname=How%20To%20Create%20Dynamic%20Condition%20Expressions%20In%20AWS%20CloudFormation%20Using%20Macros" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fhow-to-create-dynamic-condition-expressions-in-aws-cloudformation-using-macros%2F&amp;linkname=How%20To%20Create%20Dynamic%20Condition%20Expressions%20In%20AWS%20CloudFormation%20Using%20Macros" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd a2a_counter addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fhow-to-create-dynamic-condition-expressions-in-aws-cloudformation-using-macros%2F&#038;title=How%20To%20Create%20Dynamic%20Condition%20Expressions%20In%20AWS%20CloudFormation%20Using%20Macros" data-a2a-url="https://cloudnineapps.com/blogs/cloud-computing/how-to-create-dynamic-condition-expressions-in-aws-cloudformation-using-macros/" data-a2a-title="How To Create Dynamic Condition Expressions In AWS CloudFormation Using Macros"></a></p><p>The post <a rel="nofollow" href="https://cloudnineapps.com/blogs/cloud-computing/how-to-create-dynamic-condition-expressions-in-aws-cloudformation-using-macros/">How To Create Dynamic Condition Expressions In AWS CloudFormation Using Macros</a> appeared first on <a rel="nofollow" href="https://cloudnineapps.com">Cloud Nine Apps</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://cloudnineapps.com/blogs/cloud-computing/how-to-create-dynamic-condition-expressions-in-aws-cloudformation-using-macros/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">4338</post-id>	</item>
		<item>
		<title>How To Design Applications For Cloud (SaaS)</title>
		<link>https://cloudnineapps.com/blogs/cloud-computing/how-to-design-applications-for-cloud-saas/</link>
					<comments>https://cloudnineapps.com/blogs/cloud-computing/how-to-design-applications-for-cloud-saas/#respond</comments>
		
		<dc:creator><![CDATA[Nitin Patil]]></dc:creator>
		<pubDate>Wed, 06 Nov 2019 12:00:45 +0000</pubDate>
				<category><![CDATA[Cloud Computing]]></category>
		<guid isPermaLink="false">https://cloudnineapps.com/?p=4271</guid>

					<description><![CDATA[<p>How To Design Applications For Cloud (SaaS) Software as a Service (SaaS) has been a predominant model for many software vendors. It helps similarly delivering software as a Cloud vendor delivers infrastructure services. SaaS applications are often deployed on a&#8230;&#160;<a href="https://cloudnineapps.com/blogs/cloud-computing/how-to-design-applications-for-cloud-saas/" class="more-link">Read More</a></p>
<p>The post <a rel="nofollow" href="https://cloudnineapps.com/blogs/cloud-computing/how-to-design-applications-for-cloud-saas/">How To Design Applications For Cloud (SaaS)</a> appeared first on <a rel="nofollow" href="https://cloudnineapps.com">Cloud Nine Apps</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h1>How To Design Applications For Cloud (SaaS)</h1>
<p>Software as a Service (SaaS) has been a predominant model for many software vendors. It helps similarly delivering software as a Cloud vendor delivers infrastructure services. SaaS applications are often deployed on a public cloud, like Amazon Cloud (AWS), Microsoft Azure, Google Cloud and so on. However, at times the organization may choose to use their datacenter (a.k.a. private cloud) to host the SaaS application and leverage their investment in the infrastructure. When you are designing SaaS applications, it takes more than just deploying application bits to the Cloud. Taking proper design considerations can not only help you in accomplishing a good design, but it can also help you in reducing costs and manage your deployment more effectively. In this post, I will cover some key considerations and tips to design SaaS applications that I have found useful over the years.</p>
<h2>How Is Designing Applications For Cloud Different From On-premise Applications Design?</h2>
<p>That&#8217;s a valid question that many Architects face, especially in the early phases. There are certain subtle differences. Let&#8217;s look at some of these just to get the perspective.</p>
<ul>
<li><strong>Better Modularization</strong>: If you have a monolithic application with a huge footprint, it is perhaps wise to see if it can be broken into logical components that can be deployed separately. This not only improves modularity but helps you reduce the footprint of the application. Let&#8217;s say you have an application that uses background jobs to refresh data. You could segregate the core application and the background jobs as 2 (or more) components that can be deployed separately. This will reduce the footprint of the core application. So, you could potentially choose a smaller resource size. Also, depending on the needs, you can scale these two independently. So, if there is an increase in demand for background jobs, you can increase its capacity and likewise for the application tier. Since the resource size for each of these is small, scaling only the required tier/component will lead to an overall lower cost than more bulky resources for the monolith. Makes sense?</li>
<li><strong>Application is always up-to-date</strong>: This is a big shift for many on-premise applications. In the Cloud, customers typically expect the application to be always on the latest version. Now, if you think about it as an Architect it means you are not only able to update the application bits but also upgrade customer data with preferably no customer involvement. That is, it is completely transparent to them.</li>
</ul>
<p>These are just some of the differences. But, you get the point.</p>
<h2>Key Design Considerations for SaaS</h2>
<p>When you are designing an application for Cloud, you want to consider the following key points.</p>
<ul>
<li><strong>Choose appropriate Cloud services</strong>: Of course, you are deploying to Cloud. But, which services do you want to use? Are you simply going to use Infrastructure as a Service (IaaS)? Or are you going to take advantage of some Platform as a Service (PaaS) capabilities as well? The answer may not be always straightforward. So, here are some guidelines.
<ul>
<li>Are you going to have the same application deployed to multiple Cloud platforms or on-premise as well? In that case, it may make sense to not have (or minimize) Cloud vendor-specific services and stick to more of IaaS services.</li>
<li>Cost should be an important consideration in choosing the services. For example, certain PaaS services that are Cloud vendor managed may be managed by your team itself to reduce cost. While this may not make sense for every service, it is worth exploring.</li>
<li>Keep your team expertise in mind. What would it take to use a certain Cloud service? And, if the team were to also maintain the underlying infrastructure, what skills would be needed?</li>
</ul>
</li>
<li><strong>Design for failure</strong>: Designing fault-tolerant and highly available applications is fundamental to Cloud. Assume that your application will run into issues and how you will ensure that it continues to serve the users. These could be application failures or underlying infrastructure failures. There are a few useful capabilities offered by Cloud vendors to help here.
<ul>
<li><strong>Use a Load Balancer</strong>: You can put the application nodes behind a Load Balancer for both load-balancing purposes as well as to make sure that even if one or more nodes go down, the application is served via the other nodes.</li>
<li><strong>Geographically distributed application</strong>: Several Cloud vendors offer capabilities to spread the application across multiple geographical areas so that even if one area is impacted (say, due to a natural disaster), the application can be served from the other areas. For example, AWS supports deploying an application across multiple Availability Zones.</li>
</ul>
</li>
<li><strong>Modularize your application</strong>: As we discussed in the earlier section, segregating components that can be deployed and managed separately can help reduce the footprint of the application and thus reduce the cost of the infrastructure. You may also consider making some of these components as <strong>microservices</strong>. The microservice approach can be particularly useful if there are other potential consumers besides your application. Now, that does not mean, you go overboard and create unnecessary components. Hence, one way to do this is to make components that can be deployed separately (such as core application versus background jobs).</li>
<li><strong>Security</strong>: Security involves many aspects &#8211; from securing your infrastructure to application. Some of the key aspects include ensuring that only the required ports are opened, using as minimal privileges on the resources as possible, having proper role-based access control, use of encryption, and so on. Security should not be looked at as a one-time deal. It is an on-going process that should improve and evolve over time.</li>
<li><strong>Multi-tenancy</strong>: A key benefit of running in the Cloud is being able to serve multiple customers using the <span style="text-decoration: underline;">same</span> instance of the application. This brings out some obvious challenges in the application design to ensure that each customer&#8217;s data is segregated for both security and regulatory purposes. Some teams choose to go with a different persistent storage instance per customer, such as a separate database per customer. And, some choose to segregate data using row-level identifiers. Regardless of which approach you take, it is important to ensure that the architecture meets the scalability and security needs. For example, if you choose to go with a database per customer, you can host multiple databases on one RDS instance. And, when you run out of capacity, you can stand up another RDS instance.</li>
<li><strong>Zero/Minimal Downtime and Seamless Upgrades</strong>: Believe it or not, many customers expect that SaaS applications will have zero or very minimal downtime and since these are often managed by the same company who built the application, it should be upgraded seamlessly. The challenge is your application may not have been designed to handle upgrades smoothly, especially if it is a pre-existing application being converted to a SaaS application. There are 2 key aspects to consider a) deploying application bits and files b) handling persistent store upgrades. For rolling out application bits strategies like Blue/Green deployment can be used in which the new release is deployed to a new stack, tested and made live if the rollout was successful. The older stack resources can be decommissioned and reclaimed at a later point. One approach to achieve seamless upgrades is to make the underlying data model <strong>n &#8211; 1 compatible</strong>. What that means is if the release being deployed is of data model version <strong>n</strong>, it&#8217;s data model is backward compatible with the previous data model version (n &#8211; 1) thus ensuring that the upgrade will not break it. How can you ensure that? This requires incorporating discipline throughout your development cycle and following certain guidelines, like not deleting any columns, providing necessary upgrade scripts to handle any data migration needs, and so on. And, in the event upgrade is not successful, having support to <strong>rollback</strong> the upgrade. Now, you can understand this is not only technically challenging as this involves data migration and rollback, but it could also lead to a significantly slower rollout. Hence, you have to evaluate carefully what is reasonable for your application needs and implement the solution accordingly.</li>
<li><strong>Optimal Cost</strong>: As you progress through your application and deployment design, you would be able to come up with multiple approaches to deploy the same application. However, one key aspect to be successful in SaaS is to ensure that you choose the most cost-effective model that not only meets your immediate needs but can cater to at least the near future needs, such as when the demand rises or slows down. You do not want to be spending overtly, but not so less that the application starts choking with very few users. Hence, it is important to strike the right balance. A rule of thumb that I like to follow is when choosing resource sizing always go on the conservative side. And, if the testing reveals higher configuration is needed, then only increase.</li>
</ul>
<h2>DevOps Considerations For SaaS</h2>
<p>DevOps is so critical for SaaS that it is worth discussing it separately. The following are some key considerations.</p>
<ul>
<li><strong>Continuous Delivery</strong>: The DevOps pipelines should be able to take the checked-in code, produce a build from it that then passes through various stages (QA, performance, final go/no go checks, production deploy) in an <span style="text-decoration: underline;">automated</span> manner. This may involve having multiple pipelines (typically, per stage) and having an uber pipeline that pushes the build through each of these stages. Now, the pipelines may also take some time to develop, but it is a good idea to start defining the contracts for each pipeline so that the consumer pipelines do not need to worry about the details. Eventually, the goal should be to get completely hands-free or as close to it as possible.</li>
<li><strong>Use Version Control for everything including DevOps changes</strong>: For application code, it is generally well understood to use the master branch of the source control. However, it is equally important to do the same for any DevOps changes. For example, when you are rolling out infrastructure changes, these should also be checked into the source control, tested and then pushed to production.</li>
<li><strong>Agile Infrastructure</strong>: To be successful at SaaS, you want to make sure that your infrastructure is agile and can cope up with the changes in demand. As the demand goes up, it can scale appropriate tier and when the demand goes down release the non-required resources. This requires a certain level of experimentation and testing to get to the right balance. For example, you can use AWS auto-scaling capabilities to automatically scale up/down the infrastructure.</li>
<li><strong>Monitoring and Alerts</strong>: The stacks these days have multiple moving parts and troubleshooting could be a bit of a challenge. Hence, it is important to have the right monitoring and alerting mechanisms in place so that when things go wrong, you can troubleshoot the problem more quickly. It is a good idea to leverage from some of the core Cloud monitoring capabilities like centralized logging, alarms, and notifications on errors.</li>
</ul>
<h2>Other Considerations For SaaS</h2>
<ul>
<li><strong>Planning and Prioritization</strong>: Like any other successful project, SaaS projects also require planning and prioritization. While everyone wants to go for goals like &#8220;push every check in to production&#8221;, see what makes the most business sense and prioritize the important things first. Of course, having a stretch goal is not wrong. But, it is important to get the important things right first. For example, if you do not have a good unit testing and automation coverage and you are trying to push every code change to production, even if you accomplish it, the usefulness is questionable. It can backfire because things can start breaking too quickly in production and then the R&amp;D team will be consumed in handling those.</li>
<li><strong>Monetization Model</strong>: SaaS also impacts the monetization model. While in on-premise you may be fine selling license for a certain amount, in SaaS you may have to rethink what is the most suitable model for your business. Do you want to use a subscription-based model, utilization-based model, a hybrid model, or something else altogether?</li>
</ul>
<p>Hopefully, you got a better insight into what it takes to design a Cloud-based or SaaS application. It is certainly an enriching experience to see your application that involves so many different aspects, go live in production. As I always say, <em>&#8220;Cloud is a journey and not a destination&#8221;</em>. So, keep learning and evolving.</p>
<p>Happy designing!<br />
&#8211; Nitin</p>
<p><em>If you liked this post, you will find my <a href="https://cloudnineapps.com/courses/cloud-computing/aws-advanced-for-developers/" rel="noopener noreferrer">AWS Advanced For Developers</a> course helpful that focuses on many such best practices and techniques to design and deploy real-world applications in AWS.</em></p>
<p>&nbsp;</p>
<p><div class="su-note"  style="border-color:#e5d6d4;border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px;"><div class="su-note-inner su-u-clearfix su-u-trim" style="background-color:#fff0ee;border-color:#ffffff;color:#333333;border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px;"></p>
<center>
<h4>Enhance your AWS skills with these hands-on courses for real-world deployments.</h4>
</center>
<p><div class="su-row"> <div class="su-column su-column-size-1-2"><div class="su-column-inner su-u-clearfix su-u-trim"></p>
<p><a href="https://cloudnineapps.com/courses/cloud-computing/aws-cloudformation-deep-dive/"><img class="aligncenter wp-image-3758 size-medium" src="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/courses/Cloud_Computing/AWS_CloudFormation_Deep_Dive/AWS_CloudFormation_Deep_Dive_Logo.png?resize=192%2C108&#038;ssl=1" alt="" width="192" height="108" data-recalc-dims="1" /></a></p>
<center>Learn CloudFormation from concepts to hands-on examples.</center>
<p></div></div> <div class="su-column su-column-size-1-2"><div class="su-column-inner su-u-clearfix su-u-trim"></p>
<p><a href="https://cloudnineapps.com/courses/cloud-computing/aws-advanced-for-developers/"><img class="size-full wp-image-2068 aligncenter" src="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/courses/Cloud_Computing/AWS_Advanced_For_Developers/AWS_Advanced_For_Developers_Logo_small.png?resize=192%2C108&#038;ssl=1" alt="" width="192" height="108" data-recalc-dims="1" /></a></p>
<center>Learn practical application development on AWS.</center>
<p></div></div> </div></div></div></p>
<p>&nbsp;</p>
<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fhow-to-design-applications-for-cloud-saas%2F&amp;linkname=How%20To%20Design%20Applications%20For%20Cloud%20%28SaaS%29" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fhow-to-design-applications-for-cloud-saas%2F&amp;linkname=How%20To%20Design%20Applications%20For%20Cloud%20%28SaaS%29" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fhow-to-design-applications-for-cloud-saas%2F&amp;linkname=How%20To%20Design%20Applications%20For%20Cloud%20%28SaaS%29" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fhow-to-design-applications-for-cloud-saas%2F&amp;linkname=How%20To%20Design%20Applications%20For%20Cloud%20%28SaaS%29" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd a2a_counter addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fhow-to-design-applications-for-cloud-saas%2F&#038;title=How%20To%20Design%20Applications%20For%20Cloud%20%28SaaS%29" data-a2a-url="https://cloudnineapps.com/blogs/cloud-computing/how-to-design-applications-for-cloud-saas/" data-a2a-title="How To Design Applications For Cloud (SaaS)"></a></p><p>The post <a rel="nofollow" href="https://cloudnineapps.com/blogs/cloud-computing/how-to-design-applications-for-cloud-saas/">How To Design Applications For Cloud (SaaS)</a> appeared first on <a rel="nofollow" href="https://cloudnineapps.com">Cloud Nine Apps</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://cloudnineapps.com/blogs/cloud-computing/how-to-design-applications-for-cloud-saas/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">4271</post-id>	</item>
		<item>
		<title>How To Troubleshoot Connectivity Issues In AWS Deployments?</title>
		<link>https://cloudnineapps.com/blogs/cloud-computing/how-to-troubleshoot-connectivity-issues-in-aws-deployments/</link>
					<comments>https://cloudnineapps.com/blogs/cloud-computing/how-to-troubleshoot-connectivity-issues-in-aws-deployments/#respond</comments>
		
		<dc:creator><![CDATA[Nitin Patil]]></dc:creator>
		<pubDate>Mon, 14 Oct 2019 11:06:25 +0000</pubDate>
				<category><![CDATA[Cloud Computing]]></category>
		<guid isPermaLink="false">https://cloudnineapps.com/?p=4015</guid>

					<description><![CDATA[<p>How To Troubleshoot Connectivity Issues In AWS Deployments? Whether you are just learning AWS or have been using the amazon web services for some time, you will invariably run into connectivity issues in your deployments. For example, not able to&#8230;&#160;<a href="https://cloudnineapps.com/blogs/cloud-computing/how-to-troubleshoot-connectivity-issues-in-aws-deployments/" class="more-link">Read More</a></p>
<p>The post <a rel="nofollow" href="https://cloudnineapps.com/blogs/cloud-computing/how-to-troubleshoot-connectivity-issues-in-aws-deployments/">How To Troubleshoot Connectivity Issues In AWS Deployments?</a> appeared first on <a rel="nofollow" href="https://cloudnineapps.com">Cloud Nine Apps</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h1>How To Troubleshoot Connectivity Issues In AWS Deployments?</h1>
<p>Whether you are just learning AWS or have been using the amazon web services for some time, you will invariably run into connectivity issues in your deployments. For example, not able to SSH into the EC2 instance, the application tier is not able to talk to the database, and so on. In fact, there may be times when the connectivity was working fine when your stack was deployed, but it broke after some time. I am sure you can relate to at least some of these experiences. In this post, I will talk about how to troubleshoot and resolve some of the commonly encountered connectivity issues in AWS deployments.</p>
<h2>Using Telnet For Port Check</h2>
<p>Before we start talking about the issues, let&#8217;s first learn a simple technique named <strong>port check</strong> that can be used for troubleshooting. In networking, a port check refers to testing whether a port on a given node is listening or not. For example, if you want to check for the standard SSH port on a machine, you would check port <span style="font-family: courier new, courier, monospace;">22</span>. Why is a port check important? It is important because it is one of the most fundamental checks you can do for testing connectivity between two components without even knowing much about the components themselves. To explain this further, if an application running on an EC2 instance is failing to connect to the RDS instance and the port check for the database port fails from the EC2 instance, you can easily confirm that there is some connectivity issue between these two.</p>
<p>You can use the <strong>telnet</strong> utility for a port check. It is available on most platforms and is often pre-installed or can be easily installed at a later point. In order to do the port check, you will specify a command like the one shown below.</p>
<p><span style="font-family: courier new, courier, monospace;">telnet &lt;target-ip-address-or-dns-name&gt; &lt;port&gt;</span></p>
<p>If you are able to telnet successfully, the port check is successful. Otherwise, it has failed. Simple!</p>
<p>The following screenshot shows a <span style="text-decoration: underline;">successful</span> port check using telnet on an EC2 instance with the IP address <span style="font-family: courier new, courier, monospace;">10.1.0.195</span> on the SSH port <span style="font-family: courier new, courier, monospace;">22</span>.</p>
<p><a href="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Telnet_SSH_Port_Check.png?ssl=1"><img class="alignnone wp-image-4019 size-medium" src="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Telnet_SSH_Port_Check.png?resize=300%2C80&#038;ssl=1" alt="" width="300" height="80" srcset="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Telnet_SSH_Port_Check.png?resize=300%2C80&amp;ssl=1 300w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Telnet_SSH_Port_Check.png?resize=320%2C85&amp;ssl=1 320w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Telnet_SSH_Port_Check.png?resize=640%2C171&amp;ssl=1 640w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Telnet_SSH_Port_Check.png?resize=360%2C96&amp;ssl=1 360w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Telnet_SSH_Port_Check.png?resize=720%2C192&amp;ssl=1 720w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Telnet_SSH_Port_Check.png?w=742&amp;ssl=1 742w" sizes="(max-width: 300px) 100vw, 300px" data-recalc-dims="1" /></a></p>
<p>Here is another screenshot that shows a <span style="text-decoration: underline;">failed</span> port check. In this case, the telnet connection has simply hung (that is, it is not able to connect successfully). But, you may see other variants like not able to connect, etc.</p>
<p><a href="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Telnet_Not_Able_To_Connect.png?ssl=1"><img class="alignnone size-medium wp-image-4022" src="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Telnet_Not_Able_To_Connect.png?resize=300%2C44&#038;ssl=1" alt="" width="300" height="44" srcset="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Telnet_Not_Able_To_Connect.png?resize=300%2C44&amp;ssl=1 300w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Telnet_Not_Able_To_Connect.png?resize=320%2C47&amp;ssl=1 320w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Telnet_Not_Able_To_Connect.png?resize=640%2C94&amp;ssl=1 640w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Telnet_Not_Able_To_Connect.png?resize=360%2C53&amp;ssl=1 360w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Telnet_Not_Able_To_Connect.png?resize=720%2C105&amp;ssl=1 720w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Telnet_Not_Able_To_Connect.png?w=738&amp;ssl=1 738w" sizes="(max-width: 300px) 100vw, 300px" data-recalc-dims="1" /></a></p>
<h2>Common Connectivity Issues In AWS Deployments</h2>
<p>Let&#8217;s talk about some common connectivity issues in AWS deployments now. Here is a list of such issues.</p>
<ul>
<li>Not able to connect to an EC2 instance via SSH.</li>
<li>An application running on an EC2 instance is not able to connect to the RDS instance.</li>
<li>The users are not able to access the web application.</li>
</ul>
<p>These are just some of the commonly encountered issues. But, these represent some commonly observed patterns and you may find other issues that follow the same pattern. So, let&#8217;s discuss how to troubleshoot and resolve these.</p>
<h3>Not able to connect to an EC2 instance via SSH</h3>
<p>If you are not able to SSH into an EC2 instance, you can do a port check using the instance IP or DNS name on the SSH port to see if the connectivity is working at least.</p>
<p>If the port check was <span style="color: #339966;">successful</span> (that is, you were able to telnet to the SSH port), but you are still not able to connect via SSH, check for the following.</p>
<ul>
<li><strong>Use of incorrect SSH user</strong>: Although the <span style="font-family: courier new, courier, monospace;">ec2-user</span> is used quite commonly, certain AMIs use a different user. For example, the default user for the CentOS AMI is <span style="font-family: courier new, courier, monospace;">centos</span>. You can check out <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/connection-prereqs.html#connection-prereqs-get-info-about-instance" target="_blank" rel="nofollow noopener noreferrer">Get Information About Your Instance</a> to find the default user for various AMIs.</li>
</ul>
<p>However, if the port check <span style="color: #ff0000;">failed</span>, the following could be some common reasons.</p>
<ul>
<li><strong>Use of incorrect IP address or DNS name for the EC2 instance</strong>: This can happen due to a user error or the EC2 instance was rebooted and it&#8217;s public IP and DNS name changed. Now, if you have assigned an Elastic IP to the instance, it will not change upon reboot. But, Elastic IPs are expensive and used only for important instances typically. So, make sure to check the IP/DNS name is correct.</li>
<li><strong>A Firewall is blocking the SSH connection</strong>: At times, the corporate InfoSec team may block SSH connectivity to public IP addresses. This is typically done to avoid the scenario where a hacker can take advantage of an SSL vulnerability to hack into the corporate network. You can typically do some initial troubleshooting for this by using the SSH verbose option (<span style="font-family: courier new, courier, monospace;">-v</span> or <span style="font-family: courier new, courier, monospace;">-vvv</span>) when establishing the SSH connection. If that&#8217;s the case, you will need to work with your InfoSec team on the resolution. One possible solution is to assign an Elastic IP to your EC2 instance and get an exception from them to allow SSH to this IP address. Another potential firewall issue could be the OS firewall is blocking the SSH connection (such as the <span style="font-family: courier new, courier, monospace;">iptables</span> configuration). To fix this you will have to modify the firewall configuration (preferably) or turn the firewall off.</li>
<li><strong>Incorrect Security Group configuration</strong>: This is quite common especially in manual deployments wherein either the Security Group that permits SSH connectivity has not been assigned to the EC2 instance or it does not have the proper ingress rule. So, double-check the Security Group assignment and ingress rules. Remember that you can assign multiple security groups to an EC2 instance and you can change the Security Group assignment post instance creation as well. The following screenshot shows a sample security group assignment to the EC2 instance.<br />
<a href="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Security_Group_Assignment.png?ssl=1"><img class="alignnone wp-image-4024 size-large" src="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Security_Group_Assignment.png?resize=640%2C351&#038;ssl=1" alt="" width="640" height="351" srcset="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Security_Group_Assignment.png?resize=1024%2C562&amp;ssl=1 1024w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Security_Group_Assignment.png?resize=300%2C165&amp;ssl=1 300w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Security_Group_Assignment.png?resize=768%2C422&amp;ssl=1 768w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Security_Group_Assignment.png?resize=320%2C176&amp;ssl=1 320w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Security_Group_Assignment.png?resize=640%2C351&amp;ssl=1 640w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Security_Group_Assignment.png?resize=360%2C198&amp;ssl=1 360w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Security_Group_Assignment.png?resize=720%2C395&amp;ssl=1 720w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Security_Group_Assignment.png?resize=1080%2C593&amp;ssl=1 1080w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Security_Group_Assignment.png?resize=800%2C439&amp;ssl=1 800w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Security_Group_Assignment.png?resize=1280%2C703&amp;ssl=1 1280w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Security_Group_Assignment.png?w=1774&amp;ssl=1 1774w" sizes="(max-width: 640px) 100vw, 640px" data-recalc-dims="1" /></a></li>
</ul>
<h3>An application running on an EC2 instance is not able to connect to the RDS instance</h3>
<p>To troubleshoot this further, you can do a port check from the EC2 instance to the RDS instance port and see if that works.</p>
<p>The following screenshot shows a <span style="color: #339966;">successful</span> telnet port check to an RDS instance.</p>
<p><a href="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Telnet_RDS_Port_Check.png?ssl=1"><img class="alignnone wp-image-4021 size-large" src="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Telnet_RDS_Port_Check.png?resize=640%2C131&#038;ssl=1" alt="" width="640" height="131" srcset="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Telnet_RDS_Port_Check.png?resize=1024%2C210&amp;ssl=1 1024w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Telnet_RDS_Port_Check.png?resize=300%2C62&amp;ssl=1 300w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Telnet_RDS_Port_Check.png?resize=768%2C158&amp;ssl=1 768w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Telnet_RDS_Port_Check.png?resize=320%2C66&amp;ssl=1 320w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Telnet_RDS_Port_Check.png?resize=640%2C132&amp;ssl=1 640w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Telnet_RDS_Port_Check.png?resize=360%2C74&amp;ssl=1 360w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Telnet_RDS_Port_Check.png?resize=720%2C148&amp;ssl=1 720w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Telnet_RDS_Port_Check.png?resize=1080%2C222&amp;ssl=1 1080w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Telnet_RDS_Port_Check.png?resize=800%2C164&amp;ssl=1 800w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Telnet_RDS_Port_Check.png?w=1158&amp;ssl=1 1158w" sizes="(max-width: 640px) 100vw, 640px" data-recalc-dims="1" /></a></p>
<p>In that case, check for the following.</p>
<ul>
<li><strong>Use of incorrect RDS instance name or port</strong>: Check your application configuration to see if it has the correct RDS instance name and port value.</li>
</ul>
<p>If the port check <span style="color: #ff0000;">failed</span>, these could be some common reasons.</p>
<ul>
<li><strong>Use of incorrect RDS instance name or port</strong>: Double-check the instance name and port to ensure these are correct.</li>
<li><strong>Is the RDS instance up?</strong> RDS supports the shutdown of instances. This is often useful for cost control purposes when the instance is not in use. For example, shutting down a development RDS instance during the weekends. So, check if the RDS instance is available.</li>
<li><strong>Incorrect Security Group configuration</strong>: Check whether the Security Group assigned to the RDS instance has correct ingress rules to permit connectivity from the EC2 instance. This would typically involve ensuring the ingress rule has the correct source subnet (which should be your EC2 subnet) and target (database) port specified. The following screenshot shows ingress rule entries for MySQL/Aurora RDS instance.<br />
<a href="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Security_Group_DB_Ingress_Rule.png?ssl=1"><img class="alignnone wp-image-4038 size-large" src="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Security_Group_DB_Ingress_Rule.png?resize=640%2C259&#038;ssl=1" alt="" width="640" height="259" srcset="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Security_Group_DB_Ingress_Rule.png?resize=1024%2C415&amp;ssl=1 1024w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Security_Group_DB_Ingress_Rule.png?resize=300%2C121&amp;ssl=1 300w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Security_Group_DB_Ingress_Rule.png?resize=768%2C311&amp;ssl=1 768w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Security_Group_DB_Ingress_Rule.png?resize=320%2C130&amp;ssl=1 320w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Security_Group_DB_Ingress_Rule.png?resize=640%2C259&amp;ssl=1 640w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Security_Group_DB_Ingress_Rule.png?resize=360%2C146&amp;ssl=1 360w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Security_Group_DB_Ingress_Rule.png?resize=720%2C292&amp;ssl=1 720w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Security_Group_DB_Ingress_Rule.png?resize=800%2C324&amp;ssl=1 800w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Security_Group_DB_Ingress_Rule.png?w=1052&amp;ssl=1 1052w" sizes="(max-width: 640px) 100vw, 640px" data-recalc-dims="1" /></a></li>
<li><strong>Missing VPC Peering Configuration</strong>: Often resources like RDS instances are shared between application teams to reduce the cost. In such cases, the RDS instance is hosted in a different VPC (say, common VPC) and the applications are typically deployed in their own VPCs. <a href="https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html" target="_blank" rel="nofollow noopener noreferrer">VPC Peering</a> is used to connect the application VPC with the common VPC so that these can talk to the RDS instance. If the port check failed, check the VPC Peering to ensure a Peering Connection has been made between these two VPCs and route table entries have been created in <span style="text-decoration: underline;">both</span> these VPC route tables to route traffic to their respective subnets. For example, the screenshot below shows adding an entry in the common VPC route table for the application VPC subnet <span style="font-family: courier new, courier, monospace;">10.1.0.0/16</span> that is routed via the Peering Connection <span style="font-family: courier new, courier, monospace;">pcx-09fbbdba113f3bb44</span>. Similarly, an entry will need to be created in the application VPC&#8217;s route table for the common VPC subnet as the destination.<br />
<a href="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/VPC_Peering_Add_Missing_Route.png?ssl=1"><img class="alignnone wp-image-4018 size-large" src="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/VPC_Peering_Add_Missing_Route.png?resize=640%2C285&#038;ssl=1" alt="" width="640" height="285" srcset="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/VPC_Peering_Add_Missing_Route.png?resize=1024%2C456&amp;ssl=1 1024w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/VPC_Peering_Add_Missing_Route.png?resize=300%2C134&amp;ssl=1 300w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/VPC_Peering_Add_Missing_Route.png?resize=768%2C342&amp;ssl=1 768w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/VPC_Peering_Add_Missing_Route.png?resize=320%2C143&amp;ssl=1 320w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/VPC_Peering_Add_Missing_Route.png?resize=640%2C285&amp;ssl=1 640w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/VPC_Peering_Add_Missing_Route.png?resize=360%2C160&amp;ssl=1 360w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/VPC_Peering_Add_Missing_Route.png?resize=720%2C321&amp;ssl=1 720w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/VPC_Peering_Add_Missing_Route.png?resize=1080%2C481&amp;ssl=1 1080w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/VPC_Peering_Add_Missing_Route.png?resize=800%2C356&amp;ssl=1 800w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/VPC_Peering_Add_Missing_Route.png?resize=1280%2C570&amp;ssl=1 1280w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/VPC_Peering_Add_Missing_Route.png?w=1320&amp;ssl=1 1320w" sizes="(max-width: 640px) 100vw, 640px" data-recalc-dims="1" /></a></li>
</ul>
<p>Although we talked about RDS instance here, these troubleshooting techniques can be used for connectivity issues for other application stack components, such as Consul, Elasticsearch, and so on.</p>
<h3>The users are not able to access the web application</h3>
<p>Again, a port check can be used here to see if the connectivity is working.</p>
<p>If the port check is <span style="color: #339966;">successful</span>, the following could be some common reasons.</p>
<ul>
<li><strong>Application issue</strong>: Your application may be having issues. For example, the application stack may not be up or having other issues. So, check the application logs for any potential errors.</li>
<li><strong>Are you using a load balancer?</strong> For a deployment that is using a load balancer (LB), check for the instance health in load balancer setup to ensure that LB is able to use these to serve traffic. Note that LB will only serve traffic to healthy instances. If any of the instances are showing unhealthy, check their logs to troubleshoot further.</li>
</ul>
<p>If the port check <span style="color: #ff0000;">failed</span>, these could be some common reasons.</p>
<ul>
<li><strong>Use of incorrect IP address or DNS name</strong>: Ensure that the correct IP address/DNS name is being used to access the application.</li>
<li><strong>Use of incorrect port</strong>: Is your application running on a non-standard web port (that is, a port other than <span style="font-family: courier new, courier, monospace;">80</span> (for HTTP) and <span style="font-family: courier new, courier, monospace;">443</span> (for HTTPS))? For example, if you are using tomcat, the application may be running on port <span style="font-family: courier new, courier, monospace;">8080</span> instead. So, check your configuration and ensure that the correct port is being used by the users.</li>
<li><strong>Incorrect Security Group configuration</strong>: Check whether the correct Security Group has been assigned to the web tier resource(s) and verify it&#8217;s ingress rules to ensure it permits connectivity to the correct port. For example, the screenshot below shows an ingress rule to permit traffic on port <span style="font-family: courier new, courier, monospace;">8080</span> from any IP address.<br />
<a href="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Security_Group_Web_Ingress_Rule.png?ssl=1"><img class="alignnone wp-image-4037 size-large" src="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Security_Group_Web_Ingress_Rule.png?resize=640%2C116&#038;ssl=1" alt="" width="640" height="116" srcset="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Security_Group_Web_Ingress_Rule.png?resize=1024%2C186&amp;ssl=1 1024w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Security_Group_Web_Ingress_Rule.png?resize=300%2C54&amp;ssl=1 300w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Security_Group_Web_Ingress_Rule.png?resize=768%2C139&amp;ssl=1 768w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Security_Group_Web_Ingress_Rule.png?resize=320%2C58&amp;ssl=1 320w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Security_Group_Web_Ingress_Rule.png?resize=640%2C116&amp;ssl=1 640w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Security_Group_Web_Ingress_Rule.png?resize=360%2C65&amp;ssl=1 360w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Security_Group_Web_Ingress_Rule.png?resize=720%2C131&amp;ssl=1 720w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Security_Group_Web_Ingress_Rule.png?resize=1080%2C196&amp;ssl=1 1080w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Security_Group_Web_Ingress_Rule.png?resize=800%2C145&amp;ssl=1 800w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Security_Group_Web_Ingress_Rule.png?resize=1280%2C232&amp;ssl=1 1280w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/How_To_Troubleshoot_Connectivity_Issues_In_AWS_Deployments/Security_Group_Web_Ingress_Rule.png?w=1412&amp;ssl=1 1412w" sizes="(max-width: 640px) 100vw, 640px" data-recalc-dims="1" /></a></li>
</ul>
<p>In this post, we covered one of the most commonly used port check technique. It can be used in combination with other tools and techniques to effectively troubleshoot and identify the root cause. Troubleshooting connectivity issues can become a challenging task. Hence, it is important to spend some time and familiarize yourself with these tools and techniques in advance so that you are better prepared when issues arise.</p>
<p>Be a smart troubleshooter!<br />
&#8211; Nitin</p>
<p><em>If you liked this post, you will find my <a href="https://cloudnineapps.com/courses/cloud-computing/aws-advanced-for-developers/" rel="noopener noreferrer">AWS Advanced For Developers</a> course helpful that focuses on many such best practices and techniques to design and deploy real-world applications in AWS.</em></p>
<p>&nbsp;</p>
<p><div class="su-note"  style="border-color:#e5d6d4;border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px;"><div class="su-note-inner su-u-clearfix su-u-trim" style="background-color:#fff0ee;border-color:#ffffff;color:#333333;border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px;"></p>
<center>
<h4>Enhance your AWS skills with these hands-on courses for real-world deployments.</h4>
</center>
<p><div class="su-row"> <div class="su-column su-column-size-1-2"><div class="su-column-inner su-u-clearfix su-u-trim"></p>
<p><a href="https://cloudnineapps.com/courses/cloud-computing/aws-cloudformation-deep-dive/"><img class="aligncenter wp-image-3758 size-medium" src="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/courses/Cloud_Computing/AWS_CloudFormation_Deep_Dive/AWS_CloudFormation_Deep_Dive_Logo.png?resize=192%2C108&#038;ssl=1" alt="" width="192" height="108" data-recalc-dims="1" /></a></p>
<center>Learn CloudFormation from concepts to hands-on examples.</center>
<p></div></div> <div class="su-column su-column-size-1-2"><div class="su-column-inner su-u-clearfix su-u-trim"></p>
<p><a href="https://cloudnineapps.com/courses/cloud-computing/aws-advanced-for-developers/"><img class="size-full wp-image-2068 aligncenter" src="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/courses/Cloud_Computing/AWS_Advanced_For_Developers/AWS_Advanced_For_Developers_Logo_small.png?resize=192%2C108&#038;ssl=1" alt="" width="192" height="108" data-recalc-dims="1" /></a></p>
<center>Learn practical application development on AWS.</center>
<p></div></div> </div></div></div></p>
<p>&nbsp;</p>
<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fhow-to-troubleshoot-connectivity-issues-in-aws-deployments%2F&amp;linkname=How%20To%20Troubleshoot%20Connectivity%20Issues%20In%20AWS%20Deployments%3F" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fhow-to-troubleshoot-connectivity-issues-in-aws-deployments%2F&amp;linkname=How%20To%20Troubleshoot%20Connectivity%20Issues%20In%20AWS%20Deployments%3F" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fhow-to-troubleshoot-connectivity-issues-in-aws-deployments%2F&amp;linkname=How%20To%20Troubleshoot%20Connectivity%20Issues%20In%20AWS%20Deployments%3F" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fhow-to-troubleshoot-connectivity-issues-in-aws-deployments%2F&amp;linkname=How%20To%20Troubleshoot%20Connectivity%20Issues%20In%20AWS%20Deployments%3F" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd a2a_counter addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fhow-to-troubleshoot-connectivity-issues-in-aws-deployments%2F&#038;title=How%20To%20Troubleshoot%20Connectivity%20Issues%20In%20AWS%20Deployments%3F" data-a2a-url="https://cloudnineapps.com/blogs/cloud-computing/how-to-troubleshoot-connectivity-issues-in-aws-deployments/" data-a2a-title="How To Troubleshoot Connectivity Issues In AWS Deployments?"></a></p><p>The post <a rel="nofollow" href="https://cloudnineapps.com/blogs/cloud-computing/how-to-troubleshoot-connectivity-issues-in-aws-deployments/">How To Troubleshoot Connectivity Issues In AWS Deployments?</a> appeared first on <a rel="nofollow" href="https://cloudnineapps.com">Cloud Nine Apps</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://cloudnineapps.com/blogs/cloud-computing/how-to-troubleshoot-connectivity-issues-in-aws-deployments/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">4015</post-id>	</item>
		<item>
		<title>AWS CloudFormation &#8211; An Architect&#8217;s Best Friend</title>
		<link>https://cloudnineapps.com/blogs/cloud-computing/aws-cloudformation-an-architects-best-friend/</link>
					<comments>https://cloudnineapps.com/blogs/cloud-computing/aws-cloudformation-an-architects-best-friend/#respond</comments>
		
		<dc:creator><![CDATA[Nitin Patil]]></dc:creator>
		<pubDate>Wed, 18 Sep 2019 11:16:41 +0000</pubDate>
				<category><![CDATA[Cloud Computing]]></category>
		<guid isPermaLink="false">https://cloudnineapps.com/?p=3776</guid>

					<description><![CDATA[<p>AWS CloudFormation &#8211; An Architect&#8217;s Best Friend Automating the AWS deployments has been a key driver to ensure consistent and reliable deployments. Whether it is zero-touch deployments, immutable architecture or continuous delivery (CD), automated deployments are critical to successful delivery.&#8230;&#160;<a href="https://cloudnineapps.com/blogs/cloud-computing/aws-cloudformation-an-architects-best-friend/" class="more-link">Read More</a></p>
<p>The post <a rel="nofollow" href="https://cloudnineapps.com/blogs/cloud-computing/aws-cloudformation-an-architects-best-friend/">AWS CloudFormation &#8211; An Architect&#8217;s Best Friend</a> appeared first on <a rel="nofollow" href="https://cloudnineapps.com">Cloud Nine Apps</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h1>AWS CloudFormation &#8211; An Architect&#8217;s Best Friend</h1>
<p>Automating the AWS deployments has been a key driver to ensure consistent and reliable deployments. Whether it is zero-touch deployments, immutable architecture or continuous delivery (CD), automated deployments are critical to successful delivery. And, this is not just about deploying the underlying infrastructure. It is also equally applicable to the application stacks as well. AWS CloudFormation is a key service when it comes to automating AWS deployments. Be it a simple stack with a couple of resources or complex stacks that are deployed to multiple AWS regions and accounts, CloudFormation provides several useful capabilities like reusable deployment templates, powerful CLI, automatic change detection, rollback, resource dependency management, parallel deployment, and many more. In this post, we will learn some basics along with an actual example and see why is CloudFormation an Architect&#8217;s best friend!</p>
<h2>What is CloudFormation (CFN)?</h2>
<p>First things first. CloudFormation (CFN) is a service from the AWS portfolio that delivers <strong>Infrastructure as a Code</strong>. It offers the following key capabilities.</p>
<ul>
<li><strong>Automate complete infrastructure setup</strong>: Manage the complete deployment recipe of your deployment by specifying resources and their configuration. A CFN deployment is also referred to as a <em>stack</em>.</li>
<li><strong>Focus on &#8220;what&#8221; and not &#8220;how&#8221;</strong>: CFN is developed in the form of text-based templates (a.k.a. <em>CFN template</em>) in which the majority of times you specify &#8220;what to do&#8221;. For example, when you create an EC2 instance, you simply specify it&#8217;s configuration (like the instance type, storage size, etc) and not the actual commands to create the resource. This makes the templates relatively small in size and helps you focus on what you want to accomplish. Having said that it does offer (limited) scripting capabilities for common needs, such as string manipulation.</li>
<li><strong>Consistency with speed</strong>: CFN offers features like parallel deployment for faster turnaround. At the same time, the templates can be designed to ensure all deployments are consistent and avoid manual configurations altogether.</li>
<li><strong>Manage the complete lifecycle of the stack</strong>: You can create/update/delete stacks.</li>
<li><strong>Version Control Infrastructure Releases</strong>: Yes, that&#8217;s possible! Since CFN templates are text-based documents (JSON or YAML), you can simply check these into your version control and use the same standard best practices that you are used to for a typical application release. In fact, I highly recommend to only deploy from the &#8220;master&#8221; branch to production to ensure only validated changes are deployed.</li>
<li>Apart from these, it offers several other useful capabilities like <strong>dependency management</strong> between resources (dependency resources are deployed before and deleted after the dependent resources), <strong>delta detection</strong> when making updates, an <strong>automated rollback</strong> of failed deployment, and so on.</li>
<li>CFN offers a powerful CLI and SDK support for programmatic integrations. This is extremely useful for DevOps and automation purpose.</li>
</ul>
<h2>CloudFormation Core Concepts</h2>
<p>Let&#8217;s talk about some basic CFN constructs now. Keep in mind that the key idea with CFN is to have <strong>reusable templates</strong> that can be used to deploy multiple stacks typically.</p>
<ul>
<li><strong>Parameters</strong>: These are used to take user inputs and capture variables that can change between deployments from the same template. A parameter has a type (such as String) and can optionally have validation associated. AWS offers pre-defined parameters, known as <strong>Pseudo Parameters</strong>, for some useful values, such as the deployment account ID, the target region, and so on.</li>
<li><strong>Mappings</strong>: These are used to capture derived information. For example, you can specify resource attributes for different deployment type (development vs production).</li>
<li><strong>Conditions</strong>: A condition can be used to specify the conditional creation of a resource or use of a resource property.</li>
<li><strong>Resources</strong>: The resources and their configuration specified using properties.</li>
<li><strong>Outputs</strong>: A CFN template can produce outputs to provide relevant information. For example, an RDS template can provide the database instance connection information.</li>
<li><strong>Metadata</strong>: Useful metadata can be specified in the CFN template that can be consumed by other tools, such as CloudFormation Designer and automation tools. For example, CFN offers helper scripts that can use the metadata to install the software.</li>
<li><strong>Intrinsic Functions</strong>: CFN provides several useful intrinsic functions for common computing needs, such as string manipulation, resource lookup, etc. These are evaluated at deployment time.</li>
</ul>
<h2>CFN Template Example</h2>
<p>Let&#8217;s walk through an example to understand these concepts better.</p>
<pre class="lang:default decode:true">{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Description": "An EC2 instance.",
  "Parameters": {
    "InstanceName": {
      "Description": "The instance name.",
      "Type": "String"
    },
    "DeploymentType": {
      "Description": "The deployment type.",
      "Type": "String",
      "AllowedValues": ["Dev", "QA", "Prod"],
      "Default": "Dev"
    },
    "Subnet": {
      "Description": "The subnet for the EC2 instance.",
      "Type": "AWS::EC2::Subnet::Id"
    },
    "SecurityGroups": {
      "Description": "The Security Groups for the EC2 instance.",
      "Type": "List"
    },
    "KeyPair": {
      "Description": "The key pair name to use to connect to the EC2 instance.",
      "Type": "String"
    }
  },
  "Mappings": {
    "Globals": {
      "Constants": {
        "ImageId": "ami-0b898040803850657",
        "AssignPublicIP": "true"
      }
    },
    "DeploymentTypes": {
      "Dev": {
        "InstanceType": "t2.small",
        "StorageSize": "20"
      },
      "QA": {
        "InstanceType": "t2.small",
        "StorageSize": "30"
      },
      "Prod": {
        "InstanceType": "t2.medium",
        "StorageSize": "50"
      }
    }
  },
  "Resources": {
    "EC2Instance": {
      "Type": "AWS::EC2::Instance",
      "Properties": {
        "ImageId": {"Fn::FindInMap": ["Globals", "Constants", "ImageId"]},
        "InstanceType": {"Fn::FindInMap": ["DeploymentTypes", {"Ref": "DeploymentType"}, "InstanceType"]},
        "NetworkInterfaces": [{
          "DeviceIndex": "0",
          "SubnetId": {"Ref": "Subnet"},
          "AssociatePublicIpAddress": {"Fn::FindInMap": ["Globals", "Constants", "AssignPublicIP"]},
          "GroupSet": {"Ref": "SecurityGroups"}
        }],
        "BlockDeviceMappings": [{
          "DeviceName": "/dev/sdm",
          "Ebs": {
            "VolumeType": "gp2",
            "VolumeSize": {"Fn::FindInMap": ["DeploymentTypes", {"Ref": "DeploymentType"}, "StorageSize"]},
            "DeleteOnTermination": "true"
          }
        }],
        "KeyName": {"Ref": "KeyPair"},
        "Tags": [{"Key": "Name", "Value": {"Ref": "InstanceName"}}]
      },
      "Metadata": {
        "AWS::CloudFormation::Designer": {
          "id": "d0aacb0c-1b2c-452c-baf0-b283b0ba4a1a"
        }
      }
    }
  },
  "Outputs": {
    "PublicDNSName": {
      "Description": "The public DNS name.",
      "Value": {"Fn::GetAtt": ["EC2Instance", "PublicDnsName"]}
    },
    "PublicIP": {
      "Description": "The instance public IP address.",
      "Value": {"Fn::GetAtt": ["EC2Instance", "PublicIp"]}
    }
  },
  "Metadata": {
    "AWS::CloudFormation::Designer": {
      "d0aacb0c-1b2c-452c-baf0-b283b0ba4a1a": {
        "size": {
          "width": 60,
          "height": 60
        },
        "position": {
          "x": 546,
          "y": 153
        },
        "z": 0
      }
    }
  }
}
</pre>
<p>This template deploys an EC2 instance. Following are the details.</p>
<ul>
<li>The template format version and description are specified in the beginning.</li>
<li>The Parameters specifies deployment inputs that can change across stacks deployed from this template.
<ul>
<li>The <span style="font-family: courier new, courier, monospace;">InstanceName</span> parameter captures the EC2 instance name.</li>
<li>The <span style="font-family: courier new, courier, monospace;">DeploymentType</span> parameter is interesting. I call this a <strong>logical parameter</strong>. It simplifies the user experience by avoiding to ask unnecessary details from the user. At the same time, it allows customizing different EC2 instance deployments from the template by choosing from <span style="font-family: courier new, courier, monospace;">{Dev, QA or Prod}</span> values.</li>
<li>The <span style="font-family: courier new, courier, monospace;">Subnet</span> parameter is used to specify the EC2 instance subnet.</li>
<li>The <span style="font-family: courier new, courier, monospace;">SecurityGroups</span> parameter specifies the security groups to be associated with the instance.</li>
<li>The <span style="font-family: courier new, courier, monospace;">KeyPair</span> parameter takes the SSH keypair name that will be used to connect to the EC2 instance.</li>
</ul>
</li>
<li>The Mappings section specifies two top-level maps &#8211; 1) <span style="font-family: courier new, courier, monospace;">Globals</span> and <span style="font-family: courier new, courier, monospace;">DeploymentTypes</span> maps. And, each of these maps contains one or more maps that store data.
<ul>
<li>The <span style="font-family: courier new, courier, monospace;">Globals</span> map is used here to capture useful constants &#8211; the AMI ID to use and whether to assign public IP to the EC2 instance. Why would you have such a map? It&#8217;s for ease of maintenance. Tomorrow if you have to make a change, simply update the constants.</li>
<li>The <span style="font-family: courier new, courier, monospace;">DeploymentTypes</span> map specifies EC2 instance properties based on the deployment type. For example, for the <span style="font-family: courier new, courier, monospace;">Dev</span> deployment, we would like to use <span style="font-family: courier new, courier, monospace;">InstanceType</span> as <span style="font-family: courier new, courier, monospace;">t2.small</span>.</li>
</ul>
</li>
<li>It creates a single resource &#8211; an EC2 instance. This also shows why CFN is more about &#8220;what&#8221; than &#8220;how&#8221;. See we are only specifying resource configuration and not the commands to create the instance. Let CFN do it&#8217;s magic!
<ul>
<li>The <span style="font-family: courier new, courier, monospace;">ImageId</span> property is set by looking up the <span style="font-family: courier new, courier, monospace;">Globals-&gt;Constants-&gt;ImageId</span> value and using the <span style="font-family: courier new, courier, monospace;">Fn::FindInMap</span> intrinsic function.</li>
<li>The <span style="font-family: courier new, courier, monospace;">InstanceType</span> property is set by looking up the map for the <span style="font-family: courier new, courier, monospace;">DeploymentType</span>. This uses the <span style="font-family: courier new, courier, monospace;">Ref</span> intrinsic function to get the <span style="font-family: courier new, courier, monospace;">DeploymentType</span> parameter value and then passes it to the <span style="font-family: courier new, courier, monospace;">Fn::FindInMap</span> intrinsic function to retrieve the property value.</li>
<li>The <span style="font-family: courier new, courier, monospace;">NetworkInterfaces</span> property specifies a single network interface with <span style="font-family: courier new, courier, monospace;">SubnetId</span> set to the <span style="font-family: courier new, courier, monospace;">Subnet</span> parameter value, <span style="font-family: courier new, courier, monospace;">AssociatePublicIpAddress</span> set to the <span style="font-family: courier new, courier, monospace;">Globals-&gt;Constants-&gt;AssignPublicIP</span> value, and <span style="font-family: courier new, courier, monospace;">GroupSet</span> set to the <span style="font-family: courier new, courier, monospace;">SecurityGroups</span> parameter value.</li>
<li>The <span style="font-family: courier new, courier, monospace;">BlockDeviceMappings</span> property specifies a single EBS volume of type <span style="font-family: courier new, courier, monospace;">gp2</span> and size by looking up the <span style="font-family: courier new, courier, monospace;">DeploymentTypes-&gt;&lt;DeploymentType&gt;-&gt;StorageSize</span> value. For example, for a development stack, the <span style="font-family: courier new, courier, monospace;">DeploymentTypes-&gt;Dev-&gt;StorageSize</span> value will be used.</li>
<li>The <span style="font-family: courier new, courier, monospace;">KeyName</span> property is set using the <span style="font-family: courier new, courier, monospace;">KeyPair</span> parameter value.</li>
<li>The <span style="font-family: courier new, courier, monospace;">Name</span> tag is set to the <span style="font-family: courier new, courier, monospace;">InstanceName</span> parameter value.</li>
</ul>
</li>
<li>The Outputs section outputs the public DNS name and IP information using the <span style="font-family: courier new, courier, monospace;">Fn::GetAtt</span> intrinsic function to retrieve the <span style="font-family: courier new, courier, monospace;">PublicDnsName</span> and <span style="font-family: courier new, courier, monospace;">PublicIp</span> attributes of the EC2 instance, respectively.</li>
<li>The Metadata sections of this template contain the user interface data for the CFN Designer tool.</li>
</ul>
<h2>Conclusion</h2>
<p>We covered a lot of ground here. But, this is just a highlight of how powerful CFN is. It offers many more capabilities like resource <strong>dependency management</strong>, <strong>nested stacks</strong> that make it easy to dploy a hierarchy of stacks, <strong>StackSets</strong> that allow cross-region and even cross-account deployment, and more. In fact, if you have a resource that is not directly managed by AWS (or not supported by CFN), you can still manage it using CFN via a <strong>Custom Resource</strong>. So, you see the possibilities are endless and we have only scratched the surface. But, you know by now that if you are an Architect or someone who is involved in AWS deployments, CloudFormation is a tool that can help you tremendously in automating your deployments.</p>
<p>Happy deploying!<br />
&#8211; Nitin</p>
<p>&nbsp;</p>
<p><div class="su-note"  style="border-color:#e5d6d4;border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px;"><div class="su-note-inner su-u-clearfix su-u-trim" style="background-color:#fff0ee;border-color:#ffffff;color:#333333;border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px;"></p>
<center>
<h4>Enhance your AWS skills with these hands-on courses for real-world deployments.</h4>
</center>
<p><div class="su-row"> <div class="su-column su-column-size-1-2"><div class="su-column-inner su-u-clearfix su-u-trim"></p>
<p><a href="https://cloudnineapps.com/courses/cloud-computing/aws-cloudformation-deep-dive/"><img class="aligncenter wp-image-3758 size-medium" src="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/courses/Cloud_Computing/AWS_CloudFormation_Deep_Dive/AWS_CloudFormation_Deep_Dive_Logo.png?resize=192%2C108&#038;ssl=1" alt="" width="192" height="108" data-recalc-dims="1" /></a></p>
<center>Learn CloudFormation from concepts to hands-on examples.</center>
<p></div></div> <div class="su-column su-column-size-1-2"><div class="su-column-inner su-u-clearfix su-u-trim"></p>
<p><a href="https://cloudnineapps.com/courses/cloud-computing/aws-advanced-for-developers/"><img class="size-full wp-image-2068 aligncenter" src="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/courses/Cloud_Computing/AWS_Advanced_For_Developers/AWS_Advanced_For_Developers_Logo_small.png?resize=192%2C108&#038;ssl=1" alt="" width="192" height="108" data-recalc-dims="1" /></a></p>
<center>Learn practical application development on AWS.</center>
<p></div></div> </div></div></div></p>
<p>&nbsp;</p>
<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Faws-cloudformation-an-architects-best-friend%2F&amp;linkname=AWS%20CloudFormation%20%E2%80%93%20An%20Architect%E2%80%99s%20Best%20Friend" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Faws-cloudformation-an-architects-best-friend%2F&amp;linkname=AWS%20CloudFormation%20%E2%80%93%20An%20Architect%E2%80%99s%20Best%20Friend" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Faws-cloudformation-an-architects-best-friend%2F&amp;linkname=AWS%20CloudFormation%20%E2%80%93%20An%20Architect%E2%80%99s%20Best%20Friend" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Faws-cloudformation-an-architects-best-friend%2F&amp;linkname=AWS%20CloudFormation%20%E2%80%93%20An%20Architect%E2%80%99s%20Best%20Friend" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd a2a_counter addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Faws-cloudformation-an-architects-best-friend%2F&#038;title=AWS%20CloudFormation%20%E2%80%93%20An%20Architect%E2%80%99s%20Best%20Friend" data-a2a-url="https://cloudnineapps.com/blogs/cloud-computing/aws-cloudformation-an-architects-best-friend/" data-a2a-title="AWS CloudFormation – An Architect’s Best Friend"></a></p><p>The post <a rel="nofollow" href="https://cloudnineapps.com/blogs/cloud-computing/aws-cloudformation-an-architects-best-friend/">AWS CloudFormation &#8211; An Architect&#8217;s Best Friend</a> appeared first on <a rel="nofollow" href="https://cloudnineapps.com">Cloud Nine Apps</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://cloudnineapps.com/blogs/cloud-computing/aws-cloudformation-an-architects-best-friend/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3776</post-id>	</item>
		<item>
		<title>Announcing Launch of AWS CloudFormation Deep Dive Course</title>
		<link>https://cloudnineapps.com/blogs/cloud-computing/announcing-launch-of-aws-cloudformation-deep-dive-course/</link>
					<comments>https://cloudnineapps.com/blogs/cloud-computing/announcing-launch-of-aws-cloudformation-deep-dive-course/#respond</comments>
		
		<dc:creator><![CDATA[Nitin Patil]]></dc:creator>
		<pubDate>Tue, 17 Sep 2019 14:47:50 +0000</pubDate>
				<category><![CDATA[Cloud Computing]]></category>
		<guid isPermaLink="false">https://cloudnineapps.com/?p=3773</guid>

					<description><![CDATA[<p>Announcing Launch of AWS CloudFormation Deep Dive Course We are extremely glad to announce the launch of our AWS CloudFormation Deep Dive course. It focuses on using CloudFormation for automating your AWS deployments and continues the legacy of our hands-on courses&#8230;&#160;<a href="https://cloudnineapps.com/blogs/cloud-computing/announcing-launch-of-aws-cloudformation-deep-dive-course/" class="more-link">Read More</a></p>
<p>The post <a rel="nofollow" href="https://cloudnineapps.com/blogs/cloud-computing/announcing-launch-of-aws-cloudformation-deep-dive-course/">Announcing Launch of AWS CloudFormation Deep Dive Course</a> appeared first on <a rel="nofollow" href="https://cloudnineapps.com">Cloud Nine Apps</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h1>Announcing Launch of AWS CloudFormation Deep Dive Course</h1>
<p><a href="https://cloudnineapps.com/courses/cloud-computing/aws-cloudformation-deep-dive/"><img class="alignleft wp-image-3758 size-medium" src="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/courses/Cloud_Computing/AWS_CloudFormation_Deep_Dive/AWS_CloudFormation_Deep_Dive_Logo.png?resize=300%2C169&#038;ssl=1" alt="" width="300" height="169" srcset="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/courses/Cloud_Computing/AWS_CloudFormation_Deep_Dive/AWS_CloudFormation_Deep_Dive_Logo.png?resize=300%2C169&amp;ssl=1 300w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/courses/Cloud_Computing/AWS_CloudFormation_Deep_Dive/AWS_CloudFormation_Deep_Dive_Logo.png?resize=768%2C432&amp;ssl=1 768w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/courses/Cloud_Computing/AWS_CloudFormation_Deep_Dive/AWS_CloudFormation_Deep_Dive_Logo.png?resize=320%2C180&amp;ssl=1 320w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/courses/Cloud_Computing/AWS_CloudFormation_Deep_Dive/AWS_CloudFormation_Deep_Dive_Logo.png?resize=640%2C360&amp;ssl=1 640w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/courses/Cloud_Computing/AWS_CloudFormation_Deep_Dive/AWS_CloudFormation_Deep_Dive_Logo.png?resize=360%2C203&amp;ssl=1 360w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/courses/Cloud_Computing/AWS_CloudFormation_Deep_Dive/AWS_CloudFormation_Deep_Dive_Logo.png?resize=720%2C405&amp;ssl=1 720w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/courses/Cloud_Computing/AWS_CloudFormation_Deep_Dive/AWS_CloudFormation_Deep_Dive_Logo.png?resize=800%2C450&amp;ssl=1 800w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/courses/Cloud_Computing/AWS_CloudFormation_Deep_Dive/AWS_CloudFormation_Deep_Dive_Logo.png?w=960&amp;ssl=1 960w" sizes="(max-width: 300px) 100vw, 300px" data-recalc-dims="1" /></a>We are extremely glad to announce the launch of our <a href="https://cloudnineapps.com/courses/cloud-computing/aws-cloudformation-deep-dive/">AWS CloudFormation Deep Dive</a> course. It focuses on using CloudFormation for automating your AWS deployments and continues the legacy of our hands-on courses that focus on real-world deployments. AWS CloudFormation is a key service when it comes to automating AWS deployments. Be it a simple stack with a couple of resources or complex stacks that are deployed to multiple AWS regions and accounts, CloudFormation provides several useful capabilities like reusable deployment templates, powerful CLI, automatic change detection, rollback, resource dependency management, parallel deployment, and many more. This course will set a solid foundation for anyone working with AWS deployments in understanding CloudFormation core concepts to hands-on experience in deploying simple to complex stacks along with several best practices and tips.</p>
<h2>Course Overview</h2>
<p><iframe width="560" height="315" src="https://www.youtube.com/embed/Ad94vVD2cGQ" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen="allowfullscreen"></iframe></p>
<h3>Course Outline</h3>
<p>Following is an outline of the course.</p>
<ul>
<li>Overview of AWS CloudFormation (CFN)</li>
<li>Best practices and tips for using CFN in real-world deployments</li>
<li>Deep dive into CFN with detailed examples</li>
<li>Advance CloudFormation topics like Nested Stacks, StackSets, Custom Resources and Macros</li>
</ul>
<h3>Intended Audience</h3>
<ul>
<li>Application Architects</li>
<li>Cloud Deployment Designers and Practitioners</li>
<li>DevOps</li>
<li>DevOps Engineers</li>
<li>QA</li>
<li>Operations</li>
</ul>
<p><a href="https://cloudnineapps.com/courses/cloud-computing/aws-cloudformation-deep-dive/">Click here</a> to learn more and enroll.</p>
<p>&nbsp;</p>
<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fannouncing-launch-of-aws-cloudformation-deep-dive-course%2F&amp;linkname=Announcing%20Launch%20of%20AWS%20CloudFormation%20Deep%20Dive%20Course" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fannouncing-launch-of-aws-cloudformation-deep-dive-course%2F&amp;linkname=Announcing%20Launch%20of%20AWS%20CloudFormation%20Deep%20Dive%20Course" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fannouncing-launch-of-aws-cloudformation-deep-dive-course%2F&amp;linkname=Announcing%20Launch%20of%20AWS%20CloudFormation%20Deep%20Dive%20Course" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fannouncing-launch-of-aws-cloudformation-deep-dive-course%2F&amp;linkname=Announcing%20Launch%20of%20AWS%20CloudFormation%20Deep%20Dive%20Course" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd a2a_counter addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fannouncing-launch-of-aws-cloudformation-deep-dive-course%2F&#038;title=Announcing%20Launch%20of%20AWS%20CloudFormation%20Deep%20Dive%20Course" data-a2a-url="https://cloudnineapps.com/blogs/cloud-computing/announcing-launch-of-aws-cloudformation-deep-dive-course/" data-a2a-title="Announcing Launch of AWS CloudFormation Deep Dive Course"></a></p><p>The post <a rel="nofollow" href="https://cloudnineapps.com/blogs/cloud-computing/announcing-launch-of-aws-cloudformation-deep-dive-course/">Announcing Launch of AWS CloudFormation Deep Dive Course</a> appeared first on <a rel="nofollow" href="https://cloudnineapps.com">Cloud Nine Apps</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://cloudnineapps.com/blogs/cloud-computing/announcing-launch-of-aws-cloudformation-deep-dive-course/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3773</post-id>	</item>
		<item>
		<title>Not Just Another AWS CloudWatch Tutorial</title>
		<link>https://cloudnineapps.com/blogs/cloud-computing/not-just-another-aws-cloudwatch-tutorial/</link>
					<comments>https://cloudnineapps.com/blogs/cloud-computing/not-just-another-aws-cloudwatch-tutorial/#respond</comments>
		
		<dc:creator><![CDATA[Nitin Patil]]></dc:creator>
		<pubDate>Fri, 10 May 2019 11:00:34 +0000</pubDate>
				<category><![CDATA[Cloud Computing]]></category>
		<guid isPermaLink="false">https://cloudnineapps.com/?p=3319</guid>

					<description><![CDATA[<p>Not Just Another AWS CloudWatch Tutorial AWS CloudWatch plays a critical role for most deployments. It provides several capabilities from log management to generating alarms, dashboards and handling events. In this tutorial, we will cover an overview of CloudWatch, it&#8217;s&#8230;&#160;<a href="https://cloudnineapps.com/blogs/cloud-computing/not-just-another-aws-cloudwatch-tutorial/" class="more-link">Read More</a></p>
<p>The post <a rel="nofollow" href="https://cloudnineapps.com/blogs/cloud-computing/not-just-another-aws-cloudwatch-tutorial/">Not Just Another AWS CloudWatch Tutorial</a> appeared first on <a rel="nofollow" href="https://cloudnineapps.com">Cloud Nine Apps</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h1>Not Just Another AWS CloudWatch Tutorial</h1>
<p>AWS CloudWatch plays a critical role for most deployments. It provides several capabilities from log management to generating alarms, dashboards and handling events. In this tutorial, we will cover an overview of CloudWatch, it&#8217;s capabilities, basic usage, and some best practices.</p>
<h2>CloudWatch Overview</h2>
<h3>CloudWatch Key Capabilities</h3>
<figure id="attachment_3315" aria-describedby="caption-attachment-3315" style="width: 150px" class="wp-caption alignright"><a href="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/icons/3rdparty/AWS/Amazon-CloudWatch.png?ssl=1"><img class="wp-image-3315 size-full" src="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/icons/3rdparty/AWS/Amazon-CloudWatch.png?resize=150%2C150&#038;ssl=1" alt="" width="150" height="150" srcset="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/icons/3rdparty/AWS/Amazon-CloudWatch.png?w=150&amp;ssl=1 150w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/icons/3rdparty/AWS/Amazon-CloudWatch.png?resize=100%2C100&amp;ssl=1 100w" sizes="(max-width: 150px) 100vw, 150px" data-recalc-dims="1" /></a><figcaption id="caption-attachment-3315" class="wp-caption-text">(Image courtesy of AWS)</figcaption></figure>
<p>CloudWatch offers the following key capabilities.</p>
<ul>
<li><strong>Log Management</strong>:
<ul>
<li>You can publish logs to CloudWatch &#8211; both application and any system logs.</li>
<li>You can retrieve logs and also perform basic analysis using the CloudWatch console, such as searching for error messages.</li>
<li>Several services provide integration with CloudWatch, such as lambda and API Gateway. For EC2, you can use the CloudWatch agent to publish logs to CloudWatch.</li>
<li>CloudWatch is often used for log consolidation from several different components. For example, you may have logs coming from your EC2 servers, API Gateway, and so on.</li>
<li>CloudWatch is designed for scale and you can store a huge amount of logs. In fact, it does not purge out logs by default unless you set an expiry. Hence, you must make sure to set out an appropriate expiry on the Log Groups to avoid getting a huge bill.</li>
</ul>
</li>
<li><strong>Metrics</strong>
<ul>
<li>CloudWatch supports capturing metrics that can be later used for various purposes, such as reporting or taking an action. It offers several out-of-the-box metrics. For example, you could monitor the CPU utilization of your EC2 instances.</li>
<li>CloudWatch also offers <strong>AWS Custom Metrics</strong>. These metrics are provided by AWS tools, such as the CloudWatch Agent for EC2 that can report AWS Custom Metrics like memory and disk utilization.</li>
<li><strong>Custom Metrics</strong> can also be published to CloudWatch. These are often used to take advantage of CloudWatch reporting and action capabilities. For example, you could have a metric to capture errors in the logs and trigger an email when that metric count is greater than 1. A custom metric need not always be technical. You could also use it for business purpose, such as to report a transaction above a certain monetary value.</li>
</ul>
</li>
<li><strong>Alarms</strong>
<ul>
<li>An alarm is used to take one or more actions on a metric, such as send an email.</li>
<li>AWS offers various ways to evaluate alarm conditions, such as average, count, sum, etc.</li>
</ul>
</li>
<li><strong>Monitoring</strong>
<ul>
<li>CloudWatch offers several monitoring capabilities from near real-time monitoring of metrics to user-created dashboards, which are often used to monitor critical metrics.</li>
</ul>
</li>
<li><strong>Events</strong>
<ul>
<li>Events use <strong>Rules</strong> to handle changes to your AWS resources. For example, when an EC2 instance is started or stopped.</li>
<li>An Event Rule can also be scheduled, such as to periodically refresh data.</li>
</ul>
</li>
</ul>
<h3>CloudWatch Logs Overview</h3>
<p>Let&#8217;s understand some details about CloudWatch Logs.</p>
<ul>
<li>CloudWatch organizes logs into <strong>Log Groups</strong>. Think of a Log Group as a folder that represents a micro-service or component in your deployment. For example, you may have a log group for your application tier.<br />
<span style="text-decoration: underline;">Note</span>: As you can see in the screenshot below, the default expiry is set to &#8220;Never Expiry&#8221;. Hence, it is a good idea to always set this to a value that meets your deployment needs. For example, for production, you may want to keep logs up to 2 weeks old. But, for development and QA you may be fine to purge out logs that are more than 3 days old. So, configure a value as appropriate for your deployment.<br />
<a href="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Logs_Log_Groups.png?ssl=1"><img class="alignnone wp-image-3305 size-large" src="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Logs_Log_Groups.png?resize=640%2C190&#038;ssl=1" alt="" width="640" height="190" srcset="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Logs_Log_Groups.png?resize=1024%2C304&amp;ssl=1 1024w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Logs_Log_Groups.png?resize=300%2C89&amp;ssl=1 300w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Logs_Log_Groups.png?resize=768%2C228&amp;ssl=1 768w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Logs_Log_Groups.png?resize=320%2C95&amp;ssl=1 320w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Logs_Log_Groups.png?resize=640%2C190&amp;ssl=1 640w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Logs_Log_Groups.png?resize=360%2C107&amp;ssl=1 360w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Logs_Log_Groups.png?resize=720%2C214&amp;ssl=1 720w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Logs_Log_Groups.png?resize=1080%2C320&amp;ssl=1 1080w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Logs_Log_Groups.png?resize=800%2C237&amp;ssl=1 800w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Logs_Log_Groups.png?resize=1280%2C380&amp;ssl=1 1280w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Logs_Log_Groups.png?w=1790&amp;ssl=1 1790w" sizes="(max-width: 640px) 100vw, 640px" data-recalc-dims="1" /></a></li>
<li>A Log Group contains one or more <strong>Log Streams</strong>. Think of a Log Stream as a log file. For AWS services like EC2, typically there will be a Log Stream per EC2 instance. But, for other services like lambda, a Log Stream is for a chunk of time.<br />
<a href="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Logs_Log_Streams.png?ssl=1"><img class="alignnone size-large wp-image-3303" src="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Logs_Log_Streams.png?resize=640%2C138&#038;ssl=1" alt="" width="640" height="138" srcset="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Logs_Log_Streams.png?resize=1024%2C221&amp;ssl=1 1024w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Logs_Log_Streams.png?resize=300%2C65&amp;ssl=1 300w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Logs_Log_Streams.png?resize=768%2C166&amp;ssl=1 768w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Logs_Log_Streams.png?resize=320%2C69&amp;ssl=1 320w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Logs_Log_Streams.png?resize=640%2C138&amp;ssl=1 640w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Logs_Log_Streams.png?resize=360%2C78&amp;ssl=1 360w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Logs_Log_Streams.png?resize=720%2C156&amp;ssl=1 720w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Logs_Log_Streams.png?resize=1080%2C234&amp;ssl=1 1080w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Logs_Log_Streams.png?resize=800%2C173&amp;ssl=1 800w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Logs_Log_Streams.png?resize=1280%2C277&amp;ssl=1 1280w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Logs_Log_Streams.png?w=1790&amp;ssl=1 1790w" sizes="(max-width: 640px) 100vw, 640px" data-recalc-dims="1" /></a></li>
<li>Finally, we have the actual log content within a Log Stream.<br />
<a href="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Logs_Log_Stream_Log.png?ssl=1"><img class="alignnone size-large wp-image-3304" src="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Logs_Log_Stream_Log.png?resize=640%2C328&#038;ssl=1" alt="" width="640" height="328" srcset="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Logs_Log_Stream_Log.png?resize=1024%2C524&amp;ssl=1 1024w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Logs_Log_Stream_Log.png?resize=300%2C153&amp;ssl=1 300w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Logs_Log_Stream_Log.png?resize=768%2C393&amp;ssl=1 768w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Logs_Log_Stream_Log.png?resize=320%2C164&amp;ssl=1 320w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Logs_Log_Stream_Log.png?resize=640%2C327&amp;ssl=1 640w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Logs_Log_Stream_Log.png?resize=360%2C184&amp;ssl=1 360w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Logs_Log_Stream_Log.png?resize=720%2C368&amp;ssl=1 720w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Logs_Log_Stream_Log.png?resize=1080%2C553&amp;ssl=1 1080w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Logs_Log_Stream_Log.png?resize=800%2C409&amp;ssl=1 800w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Logs_Log_Stream_Log.png?resize=1280%2C655&amp;ssl=1 1280w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Logs_Log_Stream_Log.png?w=1790&amp;ssl=1 1790w" sizes="(max-width: 640px) 100vw, 640px" data-recalc-dims="1" /></a></p>
<ul>
<li>A log entry is always in the UTC time. This way you do not have to convert time into server time. This is especially useful when you have logs from different regions and multiple components.</li>
<li>CloudWatch maintains a timestamp of when the entry was published.</li>
<li>You can choose a timeframe to view the logs.</li>
<li>CloudWatch console offers basic search capabilities for analysis purpose.</li>
</ul>
</li>
</ul>
<h3>CloudWatch Metrics Overview</h3>
<p>CloudWatch offers several out-of-the-box metrics. In addition, custom metrics can also be created. Here are the key points about metrics.</p>
<ul>
<li>You can look at the currently available metrics from the <strong>Metrics</strong> view.<br />
<a href="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Metrics.png?ssl=1"><img class="alignnone size-large wp-image-3301" src="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Metrics.png?resize=640%2C334&#038;ssl=1" alt="" width="640" height="334" srcset="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Metrics.png?resize=1024%2C534&amp;ssl=1 1024w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Metrics.png?resize=300%2C157&amp;ssl=1 300w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Metrics.png?resize=768%2C401&amp;ssl=1 768w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Metrics.png?resize=320%2C167&amp;ssl=1 320w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Metrics.png?resize=640%2C334&amp;ssl=1 640w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Metrics.png?resize=360%2C188&amp;ssl=1 360w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Metrics.png?resize=720%2C376&amp;ssl=1 720w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Metrics.png?resize=1080%2C564&amp;ssl=1 1080w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Metrics.png?resize=800%2C417&amp;ssl=1 800w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Metrics.png?resize=1280%2C668&amp;ssl=1 1280w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Metrics.png?w=1790&amp;ssl=1 1790w" sizes="(max-width: 640px) 100vw, 640px" data-recalc-dims="1" /></a></li>
<li>You can drill down into a specific metric. For example, the screenshot below shows the CPUUtilization metric for a specific EC2 instance. This way you can do near real-time monitoring of the metric.<br />
<span style="text-decoration: underline;">Note</span>: You can adjust the time window based on the needs and you can also save this graph to a dashboard.<br />
<a href="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Metrics_EC2_CPU_Utilization.png?ssl=1"><img class="alignnone size-large wp-image-3300" src="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Metrics_EC2_CPU_Utilization.png?resize=640%2C473&#038;ssl=1" alt="" width="640" height="473" srcset="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Metrics_EC2_CPU_Utilization.png?resize=1024%2C756&amp;ssl=1 1024w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Metrics_EC2_CPU_Utilization.png?resize=300%2C222&amp;ssl=1 300w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Metrics_EC2_CPU_Utilization.png?resize=768%2C567&amp;ssl=1 768w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Metrics_EC2_CPU_Utilization.png?resize=320%2C236&amp;ssl=1 320w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Metrics_EC2_CPU_Utilization.png?resize=640%2C473&amp;ssl=1 640w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Metrics_EC2_CPU_Utilization.png?resize=360%2C266&amp;ssl=1 360w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Metrics_EC2_CPU_Utilization.png?resize=720%2C532&amp;ssl=1 720w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Metrics_EC2_CPU_Utilization.png?resize=1080%2C798&amp;ssl=1 1080w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Metrics_EC2_CPU_Utilization.png?resize=800%2C591&amp;ssl=1 800w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Metrics_EC2_CPU_Utilization.png?resize=1280%2C945&amp;ssl=1 1280w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Metrics_EC2_CPU_Utilization.png?w=1928&amp;ssl=1 1928w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Metrics_EC2_CPU_Utilization.png?w=1790&amp;ssl=1 1790w" sizes="(max-width: 640px) 100vw, 640px" data-recalc-dims="1" /></a></li>
</ul>
<h3>CloudWatch Alarms Overview</h3>
<p>An Alarm lets you take one or more actions when a given metric threshold is breached and also when it comes back to normal. For example, you may want to send out an alert to an infrastructure team when the CPU utilization of a critical production EC2 instance is high.</p>
<p>Following are the steps to create an alarm.</p>
<ol>
<li>Choose a metric<strong> Category</strong> to help get to the appropriate metric.<br />
<a href="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Alarm_1_Select_Metric_1.png?ssl=1"><img class="alignnone size-large wp-image-3313" src="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Alarm_1_Select_Metric_1.png?resize=640%2C414&#038;ssl=1" alt="" width="640" height="414" srcset="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Alarm_1_Select_Metric_1.png?resize=1024%2C663&amp;ssl=1 1024w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Alarm_1_Select_Metric_1.png?resize=300%2C194&amp;ssl=1 300w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Alarm_1_Select_Metric_1.png?resize=768%2C497&amp;ssl=1 768w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Alarm_1_Select_Metric_1.png?resize=320%2C207&amp;ssl=1 320w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Alarm_1_Select_Metric_1.png?resize=640%2C414&amp;ssl=1 640w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Alarm_1_Select_Metric_1.png?resize=360%2C233&amp;ssl=1 360w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Alarm_1_Select_Metric_1.png?resize=720%2C466&amp;ssl=1 720w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Alarm_1_Select_Metric_1.png?resize=1080%2C699&amp;ssl=1 1080w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Alarm_1_Select_Metric_1.png?resize=800%2C518&amp;ssl=1 800w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Alarm_1_Select_Metric_1.png?resize=1280%2C828&amp;ssl=1 1280w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Alarm_1_Select_Metric_1.png?w=1790&amp;ssl=1 1790w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Alarm_1_Select_Metric_1.png?w=2685&amp;ssl=1 2685w" sizes="(max-width: 640px) 100vw, 640px" data-recalc-dims="1" /></a></li>
<li>Select the <strong>Metric</strong>. In the screenshot below, we have selected the CPUUtilization metric for a specific EC2 instance.<br />
<a href="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Alarm_1_Select_Metric_2.png?ssl=1"><img class="alignnone size-large wp-image-3312" src="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Alarm_1_Select_Metric_2.png?resize=640%2C545&#038;ssl=1" alt="" width="640" height="545" srcset="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Alarm_1_Select_Metric_2.png?resize=1024%2C872&amp;ssl=1 1024w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Alarm_1_Select_Metric_2.png?resize=300%2C255&amp;ssl=1 300w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Alarm_1_Select_Metric_2.png?resize=768%2C654&amp;ssl=1 768w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Alarm_1_Select_Metric_2.png?resize=320%2C272&amp;ssl=1 320w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Alarm_1_Select_Metric_2.png?resize=640%2C545&amp;ssl=1 640w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Alarm_1_Select_Metric_2.png?resize=360%2C306&amp;ssl=1 360w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Alarm_1_Select_Metric_2.png?resize=720%2C613&amp;ssl=1 720w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Alarm_1_Select_Metric_2.png?resize=1080%2C919&amp;ssl=1 1080w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Alarm_1_Select_Metric_2.png?resize=800%2C681&amp;ssl=1 800w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Alarm_1_Select_Metric_2.png?resize=1280%2C1089&amp;ssl=1 1280w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Alarm_1_Select_Metric_2.png?resize=317%2C270&amp;ssl=1 317w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Alarm_1_Select_Metric_2.png?w=1790&amp;ssl=1 1790w" sizes="(max-width: 640px) 100vw, 640px" data-recalc-dims="1" /></a></li>
<li>Specify the Alarm details.<br />
<a href="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Alarm_2_Define_Alarm.png?ssl=1"><img class="alignnone size-large wp-image-3311" src="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Alarm_2_Define_Alarm.png?resize=640%2C548&#038;ssl=1" alt="" width="640" height="548" srcset="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Alarm_2_Define_Alarm.png?resize=1024%2C877&amp;ssl=1 1024w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Alarm_2_Define_Alarm.png?resize=300%2C257&amp;ssl=1 300w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Alarm_2_Define_Alarm.png?resize=768%2C657&amp;ssl=1 768w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Alarm_2_Define_Alarm.png?resize=320%2C274&amp;ssl=1 320w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Alarm_2_Define_Alarm.png?resize=640%2C548&amp;ssl=1 640w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Alarm_2_Define_Alarm.png?resize=360%2C308&amp;ssl=1 360w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Alarm_2_Define_Alarm.png?resize=720%2C616&amp;ssl=1 720w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Alarm_2_Define_Alarm.png?resize=1080%2C925&amp;ssl=1 1080w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Alarm_2_Define_Alarm.png?resize=800%2C685&amp;ssl=1 800w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Alarm_2_Define_Alarm.png?resize=1280%2C1096&amp;ssl=1 1280w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Alarm_2_Define_Alarm.png?resize=315%2C270&amp;ssl=1 315w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Alarm_2_Define_Alarm.png?w=1790&amp;ssl=1 1790w" sizes="(max-width: 640px) 100vw, 640px" data-recalc-dims="1" /></a></p>
<ul>
<li>GIve a logical name. Alarms are tied to specific resources. Hence it is useful to give a reference to the resource (or at least type of resource) in the alarm name.</li>
<li>Give a description for your reference.</li>
<li>Specify the threshold. Here we are specifying a threshold of 75% for 3 consecutive data points. That is when the CPUUtilization &gt;= 75% for 15 minutes.</li>
<li>Specify how to handle missing data. This typically happens in the initial state of alarm when data is not yet available. But, it could also happen for other metrics where the reporting may miss a cycle (such as a metric published using a CloudWatch agent).</li>
<li>Specify the actions. In this case, we are simply stopping the instance.</li>
</ul>
</li>
<li>Once the alarm has been defined, you can see it on the list of alarms. Initially, the alarm will show INSUFFICIENT_DATA until it has gathered enough metric data to go to the normal state or the alarm state.<br />
<a href="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Alarms.png?ssl=1"><img class="alignnone size-large wp-image-3314" src="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Alarms.png?resize=640%2C125&#038;ssl=1" alt="" width="640" height="125" srcset="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Alarms.png?resize=1024%2C200&amp;ssl=1 1024w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Alarms.png?resize=300%2C59&amp;ssl=1 300w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Alarms.png?resize=768%2C150&amp;ssl=1 768w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Alarms.png?resize=320%2C62&amp;ssl=1 320w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Alarms.png?resize=640%2C125&amp;ssl=1 640w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Alarms.png?resize=360%2C70&amp;ssl=1 360w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Alarms.png?resize=720%2C140&amp;ssl=1 720w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Alarms.png?resize=1080%2C211&amp;ssl=1 1080w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Alarms.png?resize=800%2C156&amp;ssl=1 800w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Alarms.png?resize=1280%2C250&amp;ssl=1 1280w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Alarms.png?w=1790&amp;ssl=1 1790w" sizes="(max-width: 640px) 100vw, 640px" data-recalc-dims="1" /></a></li>
</ol>
<h3>CloudWatch Events Overview</h3>
<p>CloudWatch Events allow handling of changes to resources, such as when an EC2 instance changes state. Let&#8217;s see how to handle a simple Event.</p>
<ol>
<li>In order to handle an Event, create an <strong>Event Rule</strong>.<br />
<a href="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Rule_1_Event_Source_Target.png?ssl=1"><img class="alignnone size-large wp-image-3310" src="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Rule_1_Event_Source_Target.png?resize=640%2C564&#038;ssl=1" alt="" width="640" height="564" srcset="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Rule_1_Event_Source_Target.png?resize=1024%2C902&amp;ssl=1 1024w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Rule_1_Event_Source_Target.png?resize=300%2C264&amp;ssl=1 300w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Rule_1_Event_Source_Target.png?resize=768%2C676&amp;ssl=1 768w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Rule_1_Event_Source_Target.png?resize=320%2C282&amp;ssl=1 320w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Rule_1_Event_Source_Target.png?resize=640%2C564&amp;ssl=1 640w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Rule_1_Event_Source_Target.png?resize=360%2C317&amp;ssl=1 360w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Rule_1_Event_Source_Target.png?resize=720%2C634&amp;ssl=1 720w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Rule_1_Event_Source_Target.png?resize=1080%2C951&amp;ssl=1 1080w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Rule_1_Event_Source_Target.png?resize=800%2C704&amp;ssl=1 800w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Rule_1_Event_Source_Target.png?resize=1280%2C1127&amp;ssl=1 1280w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Rule_1_Event_Source_Target.png?resize=307%2C270&amp;ssl=1 307w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Rule_1_Event_Source_Target.png?w=1992&amp;ssl=1 1992w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Rule_1_Event_Source_Target.png?w=1790&amp;ssl=1 1790w" sizes="(max-width: 640px) 100vw, 640px" data-recalc-dims="1" /></a></p>
<ul>
<li>Choose an <strong>Event Source</strong>. It could be an event on an AWS resource or a schedule based execution (similar to a cron job). In this screenshot, we are taking EC2 instance state change events and specifically selecting the running/stopped/terminated.</li>
<li>The Event Pattern Preview shows a sample event that the event handler can expect. This is helpful as you can copy this as a test event to test out the event handler.</li>
<li>Specify <strong>Targets</strong> that would handle the event. You can specify multiple targets. In this case, we have specified a lambda function. When the event occurs, the lambda will be passed an event similar to the one shown in the preview.</li>
</ul>
</li>
<li>Give a logical name to the rule and create it.<br />
<a href="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Rule_2_Configure_Details.png?ssl=1"><img class="alignnone size-large wp-image-3309" src="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Rule_2_Configure_Details.png?resize=640%2C197&#038;ssl=1" alt="" width="640" height="197" srcset="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Rule_2_Configure_Details.png?resize=1024%2C315&amp;ssl=1 1024w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Rule_2_Configure_Details.png?resize=300%2C92&amp;ssl=1 300w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Rule_2_Configure_Details.png?resize=768%2C236&amp;ssl=1 768w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Rule_2_Configure_Details.png?resize=320%2C98&amp;ssl=1 320w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Rule_2_Configure_Details.png?resize=640%2C197&amp;ssl=1 640w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Rule_2_Configure_Details.png?resize=360%2C111&amp;ssl=1 360w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Rule_2_Configure_Details.png?resize=720%2C221&amp;ssl=1 720w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Rule_2_Configure_Details.png?resize=1080%2C332&amp;ssl=1 1080w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Rule_2_Configure_Details.png?resize=800%2C246&amp;ssl=1 800w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Rule_2_Configure_Details.png?resize=1280%2C394&amp;ssl=1 1280w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Rule_2_Configure_Details.png?w=1996&amp;ssl=1 1996w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Rule_2_Configure_Details.png?w=1790&amp;ssl=1 1790w" sizes="(max-width: 640px) 100vw, 640px" data-recalc-dims="1" /></a></li>
<li>Once the rule is created it will show on the rules list.<br />
<a href="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Rule_3_Created.png?ssl=1"><img class="alignnone size-large wp-image-3308" src="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Rule_3_Created.png?resize=640%2C203&#038;ssl=1" alt="" width="640" height="203" srcset="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Rule_3_Created.png?resize=1024%2C324&amp;ssl=1 1024w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Rule_3_Created.png?resize=300%2C95&amp;ssl=1 300w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Rule_3_Created.png?resize=768%2C243&amp;ssl=1 768w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Rule_3_Created.png?resize=320%2C101&amp;ssl=1 320w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Rule_3_Created.png?resize=640%2C202&amp;ssl=1 640w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Rule_3_Created.png?resize=360%2C114&amp;ssl=1 360w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Rule_3_Created.png?resize=720%2C228&amp;ssl=1 720w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Rule_3_Created.png?resize=1080%2C342&amp;ssl=1 1080w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Rule_3_Created.png?resize=800%2C253&amp;ssl=1 800w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Rule_3_Created.png?resize=1280%2C405&amp;ssl=1 1280w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Rule_3_Created.png?w=1992&amp;ssl=1 1992w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CW_Create_Rule_3_Created.png?w=1790&amp;ssl=1 1790w" sizes="(max-width: 640px) 100vw, 640px" data-recalc-dims="1" /></a></li>
</ol>
<h3>CloudWatch Dashboards Overview</h3>
<p>CloudWatch Dashboards make it convenient to monitor commonly observed metrics. These are perfect for Operations teams usage and even for development and testing teams. For example, every time you run performance tests, you would want to monitor and grab the relevant widgets from the dashboard. Following is a sample dashboard that shows memory usage.</p>
<p><a href="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CloudWatch_Sample_Dashboard.png?ssl=1"><img class="alignnone size-large wp-image-3324" src="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CloudWatch_Sample_Dashboard.png?resize=640%2C376&#038;ssl=1" alt="" width="640" height="376" srcset="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CloudWatch_Sample_Dashboard.png?resize=1024%2C601&amp;ssl=1 1024w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CloudWatch_Sample_Dashboard.png?resize=300%2C176&amp;ssl=1 300w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CloudWatch_Sample_Dashboard.png?resize=768%2C451&amp;ssl=1 768w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CloudWatch_Sample_Dashboard.png?resize=320%2C188&amp;ssl=1 320w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CloudWatch_Sample_Dashboard.png?resize=640%2C376&amp;ssl=1 640w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CloudWatch_Sample_Dashboard.png?resize=360%2C211&amp;ssl=1 360w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CloudWatch_Sample_Dashboard.png?resize=720%2C423&amp;ssl=1 720w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CloudWatch_Sample_Dashboard.png?resize=1080%2C634&amp;ssl=1 1080w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CloudWatch_Sample_Dashboard.png?resize=800%2C470&amp;ssl=1 800w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_CloudWatch_Tutorial/CloudWatch_Sample_Dashboard.png?w=1240&amp;ssl=1 1240w" sizes="(max-width: 640px) 100vw, 640px" data-recalc-dims="1" /></a></p>
<ul>
<li>You can create multiple dashboards, such as one per application or even component.</li>
<li>You can add widgets to an existing dashboard from the Dashboards view or from the Metrics view. A widget shows a chart.</li>
<li>When you add a widget try keeping metrics with the same unit only so that the dashboard is easy to read.</li>
</ul>
<h2>CloudWatch Best Practices</h2>
<p>Following are some key best practices to follow for CloudWatch.</p>
<ul>
<li>Use an appropriate naming convention for CloudWatch Log Groups and Log Streams.</li>
<li>Always set an appropriate expiry for CloudWatch Log Groups. Otherwise, the consolidated logs can lead to a huge bill.</li>
<li>Like many AWS services, CloudWatch also offers a free tier. Take advantage of it. At the same time keep a watch on the resources to not exceed. Often times certain resource creation processes may create CloudWatch resources behind the scenes, such as Log Groups, alarms, etc. Make adjustments to these as needed and delete ones that you don&#8217;t need.</li>
<li>Use Dashboards for frequently monitored metrics.</li>
<li>Use metrics with the same unit on a dashboard widget.</li>
</ul>
<p>&nbsp;</p>
<p>Happy learning!<br />
&#8211; Nitin</p>
<p>&nbsp;</p>
<p><div class="su-note"  style="border-color:#e5d6d4;border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px;"><div class="su-note-inner su-u-clearfix su-u-trim" style="background-color:#fff0ee;border-color:#ffffff;color:#333333;border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px;"></p>
<center>
<h4>Enhance your AWS skills with these hands-on courses for real-world deployments.</h4>
</center>
<p><div class="su-row"> <div class="su-column su-column-size-1-2"><div class="su-column-inner su-u-clearfix su-u-trim"></p>
<p><a href="https://cloudnineapps.com/courses/cloud-computing/cloud-computing-amazon-web-services-aws-overview/"><img class="size-full wp-image-2069 aligncenter" src="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/courses/Cloud_Computing/AWS_Overview/AWS_Overview_Logo_small.png?resize=192%2C108&#038;ssl=1" alt="" width="192" height="108" data-recalc-dims="1" /></a></p>
<center>Learn AWS basics for FREE.</center>
<p></div></div> <div class="su-column su-column-size-1-2"><div class="su-column-inner su-u-clearfix su-u-trim"></p>
<p><a href="https://cloudnineapps.com/courses/cloud-computing/aws-advanced-for-developers/"><img class="size-full wp-image-2068 aligncenter" src="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/courses/Cloud_Computing/AWS_Advanced_For_Developers/AWS_Advanced_For_Developers_Logo_small.png?resize=192%2C108&#038;ssl=1" alt="" width="192" height="108" data-recalc-dims="1" /></a></p>
<center>Learn practical application development on AWS.</center>
<p></div></div> </div></div></div></p>
<p>&nbsp;</p>
<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fnot-just-another-aws-cloudwatch-tutorial%2F&amp;linkname=Not%20Just%20Another%20AWS%20CloudWatch%20Tutorial" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fnot-just-another-aws-cloudwatch-tutorial%2F&amp;linkname=Not%20Just%20Another%20AWS%20CloudWatch%20Tutorial" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fnot-just-another-aws-cloudwatch-tutorial%2F&amp;linkname=Not%20Just%20Another%20AWS%20CloudWatch%20Tutorial" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fnot-just-another-aws-cloudwatch-tutorial%2F&amp;linkname=Not%20Just%20Another%20AWS%20CloudWatch%20Tutorial" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd a2a_counter addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fnot-just-another-aws-cloudwatch-tutorial%2F&#038;title=Not%20Just%20Another%20AWS%20CloudWatch%20Tutorial" data-a2a-url="https://cloudnineapps.com/blogs/cloud-computing/not-just-another-aws-cloudwatch-tutorial/" data-a2a-title="Not Just Another AWS CloudWatch Tutorial"></a></p><p>The post <a rel="nofollow" href="https://cloudnineapps.com/blogs/cloud-computing/not-just-another-aws-cloudwatch-tutorial/">Not Just Another AWS CloudWatch Tutorial</a> appeared first on <a rel="nofollow" href="https://cloudnineapps.com">Cloud Nine Apps</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://cloudnineapps.com/blogs/cloud-computing/not-just-another-aws-cloudwatch-tutorial/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3319</post-id>	</item>
		<item>
		<title>Not Just Another AWS S3 Tutorial</title>
		<link>https://cloudnineapps.com/blogs/cloud-computing/not-just-another-aws-s3-tutorial/</link>
					<comments>https://cloudnineapps.com/blogs/cloud-computing/not-just-another-aws-s3-tutorial/#respond</comments>
		
		<dc:creator><![CDATA[Nitin Patil]]></dc:creator>
		<pubDate>Wed, 08 May 2019 16:40:19 +0000</pubDate>
				<category><![CDATA[Cloud Computing]]></category>
		<guid isPermaLink="false">https://cloudnineapps.com/?p=3266</guid>

					<description><![CDATA[<p>Not Just Another AWS S3 Tutorial Simple Storage Service (S3) was one of the initial set of AWS services and has been increasingly popular. It offers object-based storage with low latency, high durability, and availability. In this tutorial, we will&#8230;&#160;<a href="https://cloudnineapps.com/blogs/cloud-computing/not-just-another-aws-s3-tutorial/" class="more-link">Read More</a></p>
<p>The post <a rel="nofollow" href="https://cloudnineapps.com/blogs/cloud-computing/not-just-another-aws-s3-tutorial/">Not Just Another AWS S3 Tutorial</a> appeared first on <a rel="nofollow" href="https://cloudnineapps.com">Cloud Nine Apps</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h1>Not Just Another AWS S3 Tutorial</h1>
<p>Simple Storage Service (S3) was one of the initial set of AWS services and has been increasingly popular. It offers object-based storage with low latency, high durability, and availability. In this tutorial, we will cover an overview of S3, how to create a bucket, it&#8217;s basic usage and some tips.</p>
<h2>S3 Overview</h2>
<figure id="attachment_3284" aria-describedby="caption-attachment-3284" style="width: 150px" class="wp-caption alignright"><a href="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/icons/3rdparty/AWS/Amazon-Simple-Storage-Service-S3.png?ssl=1"><img class="wp-image-3284 size-full" src="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/icons/3rdparty/AWS/Amazon-Simple-Storage-Service-S3.png?resize=150%2C150&#038;ssl=1" alt="" width="150" height="150" srcset="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/icons/3rdparty/AWS/Amazon-Simple-Storage-Service-S3.png?w=150&amp;ssl=1 150w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/icons/3rdparty/AWS/Amazon-Simple-Storage-Service-S3.png?resize=100%2C100&amp;ssl=1 100w" sizes="(max-width: 150px) 100vw, 150px" data-recalc-dims="1" /></a><figcaption id="caption-attachment-3284" class="wp-caption-text">(Image courtesy of AWS)</figcaption></figure>
<p>Following are the key capabilities offered by S3.</p>
<ul>
<li>It is a <strong>Global service</strong>.</li>
<li>It offers <strong>object-based storage</strong>. Think of it as a file share in the cloud. It <span style="text-decoration: underline;">cannot</span> be used for a filesystem (such as for EC2).</li>
<li>S3 organizes objects into <strong>buckets</strong>.
<ul>
<li>A bucket belongs to an AWS region.</li>
<li>A bucket name is <span style="text-decoration: underline;">globally</span> unique. That&#8217;s right! Remember S3 is a global service.</li>
<li>An S3 bucket can be <strong>public</strong> or <strong>private</strong>. It is recommended to avoid making buckets public. If you need to share a bucket, there are other ways of sharing, which we will discuss later in this tutorial.</li>
<li>It can store multiple objects.</li>
<li>A <strong>folder</strong> hierarchy can be created to further organize the objects.</li>
</ul>
</li>
<li>S3 supports object lifecycle management capabilities like <strong>versioning</strong> and <strong>storage tiering</strong>.
<ul>
<li>Versioning allows maintaining and using multiple versions of an object.</li>
<li>Storage tiering is a popular concept in storage domain to move an object to a more aptly priced storage (typically cheaper) based on the lifecycle and access needs. For example, for data that does not need to be frequently accessed, it could be moved to Amazon Glacier, which is cheaper than keeping it in S3. This is accomplished via <strong>lifecycle policies</strong>.</li>
</ul>
</li>
<li>S3 offers <span style="text-decoration: underline;">various levels</span> of <strong>availability</strong> and <strong>durability</strong> based on the <strong>storage class</strong>. For example, the S3 Standard storage class (the default) offers high availability and durability for frequently accessed data, whereas, S3 Standard-IA (Infrequent Access) offers reduced availability as the data is intended to be infrequently accessed. S3 pricing varies based on the storage class.</li>
</ul>
<h2>Getting Started With S3</h2>
<h3>Create an S3 Bucket</h3>
<p>Let&#8217;s see how to create a bucket in S3.</p>
<ol>
<li>Go to the <strong>S3 Console</strong> and click on <strong>Create bucket</strong>.<br />
<a href="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_1_Start.png?ssl=1"><img class="alignnone size-large wp-image-3281" src="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_1_Start.png?resize=640%2C509&#038;ssl=1" alt="" width="640" height="509" srcset="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_1_Start.png?resize=1024%2C815&amp;ssl=1 1024w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_1_Start.png?resize=300%2C239&amp;ssl=1 300w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_1_Start.png?resize=768%2C611&amp;ssl=1 768w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_1_Start.png?resize=320%2C255&amp;ssl=1 320w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_1_Start.png?resize=640%2C509&amp;ssl=1 640w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_1_Start.png?resize=360%2C287&amp;ssl=1 360w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_1_Start.png?resize=720%2C573&amp;ssl=1 720w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_1_Start.png?resize=1080%2C860&amp;ssl=1 1080w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_1_Start.png?resize=800%2C637&amp;ssl=1 800w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_1_Start.png?resize=1280%2C1019&amp;ssl=1 1280w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_1_Start.png?resize=339%2C270&amp;ssl=1 339w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_1_Start.png?w=1790&amp;ssl=1 1790w" sizes="(max-width: 640px) 100vw, 640px" data-recalc-dims="1" /></a></li>
<li>Specify a <span style="text-decoration: underline;">universally unique</span> <strong>bucket name</strong> and choose a region in which the bucket will be hosted. Typically, you would choose the region based on your application or consumers who would be accessing this bucket. You can also choose to copy settings from another bucket here.<br />
<span style="text-decoration: underline;">Note</span>: If you are practicing the instructions covered in this tutorial, make sure to choose a different bucket name than the one shown here since it has to be globally unique.<br />
<a href="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_2_Bucket_Name_Region.png?ssl=1"><img class="alignnone size-large wp-image-3280" src="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_2_Bucket_Name_Region.png?resize=640%2C724&#038;ssl=1" alt="" width="640" height="724" srcset="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_2_Bucket_Name_Region.png?resize=905%2C1024&amp;ssl=1 905w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_2_Bucket_Name_Region.png?resize=265%2C300&amp;ssl=1 265w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_2_Bucket_Name_Region.png?resize=768%2C869&amp;ssl=1 768w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_2_Bucket_Name_Region.png?resize=320%2C362&amp;ssl=1 320w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_2_Bucket_Name_Region.png?resize=640%2C724&amp;ssl=1 640w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_2_Bucket_Name_Region.png?resize=360%2C407&amp;ssl=1 360w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_2_Bucket_Name_Region.png?resize=720%2C814&amp;ssl=1 720w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_2_Bucket_Name_Region.png?resize=1080%2C1221&amp;ssl=1 1080w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_2_Bucket_Name_Region.png?resize=800%2C905&amp;ssl=1 800w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_2_Bucket_Name_Region.png?resize=1024%2C1158&amp;ssl=1 1024w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_2_Bucket_Name_Region.png?resize=1280%2C1448&amp;ssl=1 1280w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_2_Bucket_Name_Region.png?resize=239%2C270&amp;ssl=1 239w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_2_Bucket_Name_Region.png?resize=300%2C339&amp;ssl=1 300w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_2_Bucket_Name_Region.png?w=1390&amp;ssl=1 1390w" sizes="(max-width: 640px) 100vw, 640px" data-recalc-dims="1" /></a></li>
<li>You can set additional <strong>properties</strong> on the bucket.<br />
<a href="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_3_Bucket_Properties.png?ssl=1"><img class="alignnone wp-image-3279 size-large" src="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_3_Bucket_Properties.png?resize=640%2C719&#038;ssl=1" alt="" width="640" height="719" srcset="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_3_Bucket_Properties.png?resize=912%2C1024&amp;ssl=1 912w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_3_Bucket_Properties.png?resize=267%2C300&amp;ssl=1 267w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_3_Bucket_Properties.png?resize=768%2C862&amp;ssl=1 768w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_3_Bucket_Properties.png?resize=320%2C359&amp;ssl=1 320w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_3_Bucket_Properties.png?resize=640%2C719&amp;ssl=1 640w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_3_Bucket_Properties.png?resize=360%2C404&amp;ssl=1 360w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_3_Bucket_Properties.png?resize=720%2C809&amp;ssl=1 720w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_3_Bucket_Properties.png?resize=1080%2C1213&amp;ssl=1 1080w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_3_Bucket_Properties.png?resize=800%2C898&amp;ssl=1 800w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_3_Bucket_Properties.png?resize=1024%2C1150&amp;ssl=1 1024w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_3_Bucket_Properties.png?resize=1280%2C1437&amp;ssl=1 1280w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_3_Bucket_Properties.png?resize=240%2C270&amp;ssl=1 240w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_3_Bucket_Properties.png?resize=300%2C337&amp;ssl=1 300w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_3_Bucket_Properties.png?w=1382&amp;ssl=1 1382w" sizes="(max-width: 640px) 100vw, 640px" data-recalc-dims="1" /></a></p>
<ul>
<li>A couple of interesting ones are versioning and encryption. Encryption is used to encrypt the data at rest, which is often required for security and compliance purpose.
<ul>
<li>S3 offers various types of encryptions from <strong>Server-Side Encryption</strong> with S3 managed keys (SSE-S3) to customer-managed keys.</li>
<li>Of course, you can also use client-side encryption in which first the files are encrypted by the client and then uploaded to S3.</li>
</ul>
</li>
</ul>
</li>
<li>Set the bucket <strong>permissions</strong> to specify who can access it. It is recommended to not make the bucket public. Also, keep the original permission here for the owner only. We will see later in this tutorial how to share a bucket with others.<br />
<a href="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_4_Bucket_Permissions.png?ssl=1"><img class="alignnone size-large wp-image-3278" src="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_4_Bucket_Permissions.png?resize=640%2C725&#038;ssl=1" alt="" width="640" height="725" srcset="https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_4_Bucket_Permissions.png?resize=904%2C1024&amp;ssl=1 904w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_4_Bucket_Permissions.png?resize=265%2C300&amp;ssl=1 265w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_4_Bucket_Permissions.png?resize=768%2C870&amp;ssl=1 768w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_4_Bucket_Permissions.png?resize=320%2C362&amp;ssl=1 320w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_4_Bucket_Permissions.png?resize=640%2C725&amp;ssl=1 640w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_4_Bucket_Permissions.png?resize=360%2C408&amp;ssl=1 360w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_4_Bucket_Permissions.png?resize=720%2C815&amp;ssl=1 720w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_4_Bucket_Permissions.png?resize=1080%2C1223&amp;ssl=1 1080w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_4_Bucket_Permissions.png?resize=800%2C906&amp;ssl=1 800w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_4_Bucket_Permissions.png?resize=1024%2C1160&amp;ssl=1 1024w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_4_Bucket_Permissions.png?resize=1280%2C1450&amp;ssl=1 1280w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_4_Bucket_Permissions.png?resize=238%2C270&amp;ssl=1 238w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_4_Bucket_Permissions.png?resize=300%2C340&amp;ssl=1 300w, https://i2.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_4_Bucket_Permissions.png?w=1374&amp;ssl=1 1374w" sizes="(max-width: 640px) 100vw, 640px" data-recalc-dims="1" /></a></li>
<li>Review the details and create the bucket.<br />
<a href="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_5_Review.png?ssl=1"><img class="alignnone size-large wp-image-3277" src="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_5_Review.png?resize=640%2C724&#038;ssl=1" alt="" width="640" height="724" srcset="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_5_Review.png?resize=905%2C1024&amp;ssl=1 905w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_5_Review.png?resize=265%2C300&amp;ssl=1 265w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_5_Review.png?resize=768%2C869&amp;ssl=1 768w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_5_Review.png?resize=320%2C362&amp;ssl=1 320w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_5_Review.png?resize=640%2C724&amp;ssl=1 640w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_5_Review.png?resize=360%2C407&amp;ssl=1 360w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_5_Review.png?resize=720%2C815&amp;ssl=1 720w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_5_Review.png?resize=1080%2C1222&amp;ssl=1 1080w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_5_Review.png?resize=800%2C905&amp;ssl=1 800w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_5_Review.png?resize=1024%2C1159&amp;ssl=1 1024w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_5_Review.png?resize=1280%2C1448&amp;ssl=1 1280w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_5_Review.png?resize=239%2C270&amp;ssl=1 239w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_5_Review.png?resize=300%2C339&amp;ssl=1 300w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Create_Bucket_5_Review.png?w=1370&amp;ssl=1 1370w" sizes="(max-width: 640px) 100vw, 640px" data-recalc-dims="1" /></a></li>
<li>Once the bucket has been created, it will appear on the list of buckets.<br />
<a href="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Buckets.png?ssl=1"><img class="alignnone size-large wp-image-3282" src="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Buckets.png?resize=640%2C164&#038;ssl=1" alt="" width="640" height="164" srcset="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Buckets.png?resize=1024%2C263&amp;ssl=1 1024w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Buckets.png?resize=300%2C77&amp;ssl=1 300w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Buckets.png?resize=768%2C197&amp;ssl=1 768w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Buckets.png?resize=320%2C82&amp;ssl=1 320w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Buckets.png?resize=640%2C164&amp;ssl=1 640w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Buckets.png?resize=360%2C92&amp;ssl=1 360w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Buckets.png?resize=720%2C185&amp;ssl=1 720w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Buckets.png?resize=1080%2C277&amp;ssl=1 1080w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Buckets.png?resize=800%2C205&amp;ssl=1 800w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Buckets.png?resize=1280%2C328&amp;ssl=1 1280w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Buckets.png?w=1790&amp;ssl=1 1790w" sizes="(max-width: 640px) 100vw, 640px" data-recalc-dims="1" /></a></li>
</ol>
<h3>Upload a File to S3</h3>
<p>We can now upload a file to our S3 bucket using the following steps.</p>
<ol>
<li>Click on the bucket and select <strong>Upload</strong>.<br />
<a href="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_1_Add_Files.png?ssl=1"><img class="alignnone size-large wp-image-3275" src="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_1_Add_Files.png?resize=640%2C488&#038;ssl=1" alt="" width="640" height="488" srcset="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_1_Add_Files.png?resize=1024%2C781&amp;ssl=1 1024w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_1_Add_Files.png?resize=300%2C229&amp;ssl=1 300w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_1_Add_Files.png?resize=768%2C586&amp;ssl=1 768w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_1_Add_Files.png?resize=320%2C244&amp;ssl=1 320w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_1_Add_Files.png?resize=640%2C488&amp;ssl=1 640w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_1_Add_Files.png?resize=360%2C275&amp;ssl=1 360w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_1_Add_Files.png?resize=720%2C549&amp;ssl=1 720w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_1_Add_Files.png?resize=1080%2C824&amp;ssl=1 1080w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_1_Add_Files.png?resize=800%2C610&amp;ssl=1 800w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_1_Add_Files.png?resize=1280%2C976&amp;ssl=1 1280w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_1_Add_Files.png?resize=354%2C270&amp;ssl=1 354w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_1_Add_Files.png?w=2022&amp;ssl=1 2022w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_1_Add_Files.png?w=1790&amp;ssl=1 1790w" sizes="(max-width: 640px) 100vw, 640px" data-recalc-dims="1" /></a></li>
<li>Add the files to upload.<br />
<a href="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_2_Select_Files.png?ssl=1"><img class="alignnone size-large wp-image-3274" src="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_2_Select_Files.png?resize=640%2C493&#038;ssl=1" alt="" width="640" height="493" srcset="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_2_Select_Files.png?resize=1024%2C789&amp;ssl=1 1024w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_2_Select_Files.png?resize=300%2C231&amp;ssl=1 300w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_2_Select_Files.png?resize=768%2C592&amp;ssl=1 768w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_2_Select_Files.png?resize=320%2C247&amp;ssl=1 320w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_2_Select_Files.png?resize=640%2C493&amp;ssl=1 640w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_2_Select_Files.png?resize=360%2C277&amp;ssl=1 360w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_2_Select_Files.png?resize=720%2C555&amp;ssl=1 720w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_2_Select_Files.png?resize=1080%2C832&amp;ssl=1 1080w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_2_Select_Files.png?resize=800%2C617&amp;ssl=1 800w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_2_Select_Files.png?resize=1280%2C986&amp;ssl=1 1280w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_2_Select_Files.png?resize=350%2C270&amp;ssl=1 350w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_2_Select_Files.png?w=1378&amp;ssl=1 1378w" sizes="(max-width: 640px) 100vw, 640px" data-recalc-dims="1" /></a></li>
<li>Specify the permissions. Here you can choose to override the permissions just for the object(s) being uploaded. In most cases, you&#8217;ll just go with the defaults.<br />
<a href="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_3_Set_Permissions.png?ssl=1"><img class="alignnone size-large wp-image-3273" src="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_3_Set_Permissions.png?resize=640%2C628&#038;ssl=1" alt="" width="640" height="628" srcset="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_3_Set_Permissions.png?resize=1024%2C1004&amp;ssl=1 1024w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_3_Set_Permissions.png?resize=300%2C294&amp;ssl=1 300w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_3_Set_Permissions.png?resize=768%2C753&amp;ssl=1 768w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_3_Set_Permissions.png?resize=320%2C314&amp;ssl=1 320w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_3_Set_Permissions.png?resize=640%2C628&amp;ssl=1 640w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_3_Set_Permissions.png?resize=360%2C353&amp;ssl=1 360w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_3_Set_Permissions.png?resize=720%2C706&amp;ssl=1 720w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_3_Set_Permissions.png?resize=1080%2C1059&amp;ssl=1 1080w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_3_Set_Permissions.png?resize=800%2C785&amp;ssl=1 800w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_3_Set_Permissions.png?resize=1280%2C1256&amp;ssl=1 1280w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_3_Set_Permissions.png?resize=275%2C270&amp;ssl=1 275w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_3_Set_Permissions.png?w=1362&amp;ssl=1 1362w" sizes="(max-width: 640px) 100vw, 640px" data-recalc-dims="1" /></a></li>
<li>Set various properties based on the needs, such as Storage class and Encryption.<br />
<a href="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_4_Set_Properties.png?ssl=1"><img class="alignnone size-large wp-image-3272" src="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_4_Set_Properties.png?resize=640%2C629&#038;ssl=1" alt="" width="640" height="629" srcset="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_4_Set_Properties.png?resize=1024%2C1006&amp;ssl=1 1024w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_4_Set_Properties.png?resize=300%2C295&amp;ssl=1 300w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_4_Set_Properties.png?resize=768%2C754&amp;ssl=1 768w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_4_Set_Properties.png?resize=320%2C314&amp;ssl=1 320w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_4_Set_Properties.png?resize=640%2C629&amp;ssl=1 640w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_4_Set_Properties.png?resize=360%2C354&amp;ssl=1 360w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_4_Set_Properties.png?resize=720%2C707&amp;ssl=1 720w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_4_Set_Properties.png?resize=1080%2C1061&amp;ssl=1 1080w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_4_Set_Properties.png?resize=800%2C786&amp;ssl=1 800w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_4_Set_Properties.png?resize=1280%2C1257&amp;ssl=1 1280w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_4_Set_Properties.png?resize=275%2C270&amp;ssl=1 275w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_4_Set_Properties.png?w=1364&amp;ssl=1 1364w" sizes="(max-width: 640px) 100vw, 640px" data-recalc-dims="1" /></a></li>
<li>Review the details and upload the file.<br />
<a href="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_5_Review.png?ssl=1"><img class="alignnone size-large wp-image-3271" src="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_5_Review.png?resize=640%2C623&#038;ssl=1" alt="" width="640" height="623" srcset="https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_5_Review.png?resize=1024%2C997&amp;ssl=1 1024w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_5_Review.png?resize=300%2C292&amp;ssl=1 300w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_5_Review.png?resize=768%2C748&amp;ssl=1 768w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_5_Review.png?resize=320%2C312&amp;ssl=1 320w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_5_Review.png?resize=640%2C623&amp;ssl=1 640w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_5_Review.png?resize=360%2C351&amp;ssl=1 360w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_5_Review.png?resize=720%2C701&amp;ssl=1 720w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_5_Review.png?resize=1080%2C1052&amp;ssl=1 1080w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_5_Review.png?resize=800%2C779&amp;ssl=1 800w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_5_Review.png?resize=1280%2C1246&amp;ssl=1 1280w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_5_Review.png?resize=277%2C270&amp;ssl=1 277w, https://i1.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Upload_File_5_Review.png?w=1366&amp;ssl=1 1366w" sizes="(max-width: 640px) 100vw, 640px" data-recalc-dims="1" /></a></li>
<li>The file will now show up under the bucket.<br />
<a href="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Bucket_Objects.png?ssl=1"><img class="alignnone size-large wp-image-3283" src="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Bucket_Objects.png?resize=640%2C252&#038;ssl=1" alt="" width="640" height="252" srcset="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Bucket_Objects.png?resize=1024%2C403&amp;ssl=1 1024w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Bucket_Objects.png?resize=300%2C118&amp;ssl=1 300w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Bucket_Objects.png?resize=768%2C303&amp;ssl=1 768w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Bucket_Objects.png?resize=320%2C126&amp;ssl=1 320w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Bucket_Objects.png?resize=640%2C252&amp;ssl=1 640w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Bucket_Objects.png?resize=360%2C142&amp;ssl=1 360w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Bucket_Objects.png?resize=720%2C284&amp;ssl=1 720w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Bucket_Objects.png?resize=1080%2C425&amp;ssl=1 1080w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Bucket_Objects.png?resize=800%2C315&amp;ssl=1 800w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Bucket_Objects.png?resize=1280%2C504&amp;ssl=1 1280w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Bucket_Objects.png?w=1790&amp;ssl=1 1790w" sizes="(max-width: 640px) 100vw, 640px" data-recalc-dims="1" /></a></li>
<li>You can click on the file to get more details and perform actions on it. You can find various details like size and the download link.<br />
<a href="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Object_Info.png?ssl=1"><img class="alignnone size-large wp-image-3276" src="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Object_Info.png?resize=640%2C680&#038;ssl=1" alt="" width="640" height="680" srcset="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Object_Info.png?resize=964%2C1024&amp;ssl=1 964w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Object_Info.png?resize=282%2C300&amp;ssl=1 282w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Object_Info.png?resize=768%2C816&amp;ssl=1 768w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Object_Info.png?resize=320%2C340&amp;ssl=1 320w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Object_Info.png?resize=640%2C680&amp;ssl=1 640w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Object_Info.png?resize=360%2C383&amp;ssl=1 360w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Object_Info.png?resize=720%2C765&amp;ssl=1 720w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Object_Info.png?resize=1080%2C1148&amp;ssl=1 1080w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Object_Info.png?resize=800%2C850&amp;ssl=1 800w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Object_Info.png?resize=1024%2C1088&amp;ssl=1 1024w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Object_Info.png?resize=254%2C270&amp;ssl=1 254w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Object_Info.png?resize=300%2C319&amp;ssl=1 300w, https://i0.wp.com/cloudnineapps.com/wp-content/uploads/blogs/CloudComputing/AWS_S3_Tutorial/S3_Object_Info.png?w=1150&amp;ssl=1 1150w" sizes="(max-width: 640px) 100vw, 640px" data-recalc-dims="1" /></a></li>
</ol>
<h3>S3 Bucket and Object Management</h3>
<p>Once you have the buckets and objects in S3, here are some commonly performed operations.</p>
<ul>
<li>Get objects</li>
<li>Update objects</li>
<li>Delete objects</li>
<li>Add more objects to buckets</li>
<li>List objects in a given bucket</li>
<li>Delete bucket</li>
</ul>
<h2><a name="understanding_s3_bucket_policies"></a>Understanding S3 Bucket Policies</h2>
<p>A bucket policy enables access and type of actions permitted on a given S3 bucket. As such, these are applied at the bucket level and apply to all objects within the bucket. Following are some key capabilities offered by the bucket policies.</p>
<ul>
<li>Grant access to specific IAM users.</li>
<li>Share a bucket with one or more AWS accounts without making it public.</li>
<li>Restrict access to the bucket to a certain domain or set of IP addresses. A use case for this would be if you are storing content for your website on S3 and want to make sure that only requests from your site are able to access the S3 bucket objects.</li>
</ul>
<p>Let&#8217;s take a look at a sample bucket policy.</p>
<pre class="lang:default decode:true">{
  "Version":"2012-10-17",
  "Statement":[
    {
      "Sid":"AllowAccessFromSpecificIP",
      "Effect":"Allow",
      "Principal":"*",
      "Action": "s3:GetObject",
      "Resource":"arn:aws:s3:::cloudnineapps-demo/*",
      "Condition": {
        "IpAddress": {
          "aws:SourceIp": [
             "your-public-ip-address/32"
          ]
        }
      }
    }
  ]
}</pre>
<p>A bucket policy has a structure similar to an <a href="https://cloudnineapps.com/blogs/cloud-computing/not-just-another-aws-iam-tutorial/#understanding_iam_policies" rel="noopener">IAM Policy</a>. This policy enables only a specific IP address to get the objects from the <span style="font-family: courier new, courier, monospace;">cloudnineapps-demo</span> bucket. Let&#8217;s review its details.</p>
<ul>
<li>The <strong>Principal</strong> specifies the target for access. In this case, it applies to all.</li>
<li>We are only providing permission to get objects from the bucket.</li>
<li>The <strong>Resource</strong> specifies the target bucket.</li>
<li>The <strong>Condition</strong> specifies additional criteria. In this case, we are allowing access from a specific IP address that should be provided in place of the text <span style="font-family: courier new, courier, monospace;">your-public-ip-address</span>.</li>
</ul>
<h2>S3 Best Practices</h2>
<p>Following are some key best practices to follow for S3.</p>
<ul>
<li>Avoid making S3 buckets public.</li>
<li>Use bucket policies for controlling access to the bucket (including sharing with other AWS accounts).</li>
<li>Use Server-Side Encryption to encrypt the data at rest.</li>
<li>Make it a practice to periodically review the buckets and their content to ensure any stale content is purged out to save cost.</li>
</ul>
<p>&nbsp;</p>
<p>Happy learning!<br />
&#8211; Nitin</p>
<p>&nbsp;</p>
<p><div class="su-note"  style="border-color:#e5d6d4;border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px;"><div class="su-note-inner su-u-clearfix su-u-trim" style="background-color:#fff0ee;border-color:#ffffff;color:#333333;border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px;"></p>
<center>
<h4>Enhance your AWS skills with these hands-on courses for real-world deployments.</h4>
</center>
<p><div class="su-row"> <div class="su-column su-column-size-1-2"><div class="su-column-inner su-u-clearfix su-u-trim"></p>
<p><a href="https://cloudnineapps.com/courses/cloud-computing/cloud-computing-amazon-web-services-aws-overview/"><img class="size-full wp-image-2069 aligncenter" src="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/courses/Cloud_Computing/AWS_Overview/AWS_Overview_Logo_small.png?resize=192%2C108&#038;ssl=1" alt="" width="192" height="108" data-recalc-dims="1" /></a></p>
<center>Learn AWS basics for FREE.</center>
<p></div></div> <div class="su-column su-column-size-1-2"><div class="su-column-inner su-u-clearfix su-u-trim"></p>
<p><a href="https://cloudnineapps.com/courses/cloud-computing/aws-advanced-for-developers/"><img class="size-full wp-image-2068 aligncenter" src="https://i0.wp.com/cloudnineapps.com/wp-content/uploads/courses/Cloud_Computing/AWS_Advanced_For_Developers/AWS_Advanced_For_Developers_Logo_small.png?resize=192%2C108&#038;ssl=1" alt="" width="192" height="108" data-recalc-dims="1" /></a></p>
<center>Learn practical application development on AWS.</center>
<p></div></div> </div></div></div></p>
<p>&nbsp;</p>
<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fnot-just-another-aws-s3-tutorial%2F&amp;linkname=Not%20Just%20Another%20AWS%20S3%20Tutorial" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fnot-just-another-aws-s3-tutorial%2F&amp;linkname=Not%20Just%20Another%20AWS%20S3%20Tutorial" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fnot-just-another-aws-s3-tutorial%2F&amp;linkname=Not%20Just%20Another%20AWS%20S3%20Tutorial" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fnot-just-another-aws-s3-tutorial%2F&amp;linkname=Not%20Just%20Another%20AWS%20S3%20Tutorial" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd a2a_counter addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fcloudnineapps.com%2Fblogs%2Fcloud-computing%2Fnot-just-another-aws-s3-tutorial%2F&#038;title=Not%20Just%20Another%20AWS%20S3%20Tutorial" data-a2a-url="https://cloudnineapps.com/blogs/cloud-computing/not-just-another-aws-s3-tutorial/" data-a2a-title="Not Just Another AWS S3 Tutorial"></a></p><p>The post <a rel="nofollow" href="https://cloudnineapps.com/blogs/cloud-computing/not-just-another-aws-s3-tutorial/">Not Just Another AWS S3 Tutorial</a> appeared first on <a rel="nofollow" href="https://cloudnineapps.com">Cloud Nine Apps</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://cloudnineapps.com/blogs/cloud-computing/not-just-another-aws-s3-tutorial/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3266</post-id>	</item>
	</channel>
</rss>
