Compliance Check for EC2 and S3 Using AWS Config
Tags: aws, ec2, s3, awsconfig
Published: 2023-03-18 10:40:40

“ I have checked the documents of AWS to resolve the issue of compliance check for AWS services. So I got AWS Config for compliance purposes. Pricing of AWS Config depends on configuration item and rule created.”

AWS Config continually assesses, audits and evaluates the configurations and relationships of your resources on AWS, on premises and on other clouds.

In this post, you will get to know how to do compliance check for ec2 and s3 using aws config. Here I have used an ec2 server and a s3 bucket for compliance check on this using config service rules.

#Prerequisites
You’ll need an Amazon EC2 Server for this post. [Getting started with amazon EC2](https://aws.amazon.com/ec2/getting-started/) provides instructions on how to launch an EC2 Server.

You’ll need an Amazon Simple Storage Service for this post. [Getting started with Amazon Simple Storage Service](https://aws.amazon.com/s3/getting-started/) provides instructions on how to create a bucket in simple storage service. For this blog, I assume that I have an ec2 server and a s3 bucket created.

#Architecture Overview
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i0nrm5bj6fknhcc64k5p.png)
The architecture diagram shows the overall deployment architecture with data flow, amazon ec2, amazon s3 and aws config.

#Solution overview
The blog post consists of the following phases:
1. Create Rules for EC2 and S3 Compliance in AWS Config
2. Enable Block Public Access Option in S3 Bucket for Compliance Purpose

I have a s3 bucket and a ec2 server as below →
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iua7go83xuk160fmjml5.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g5qizap2uhqok0g5it9e.png)

##Phase 1: Create Rules for EC2 and S3 Compliance in AWS Config  
1. Open the AWS Config console and add an AWS managed rule for ec2 and s3 service. Once the rule is created, open the resource inventory and checkout the compliant and noncompliant rule.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b5syohg7hiyqiqp75jw4.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g3cprqw5ovs5vldsi2mp.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cz1j6k5dwa8ynsf7y2a7.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/giwv2cw59dg0glnxxgop.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0l6o8wsekhlx5ppuobdg.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m92ydnwtgv6l37zb863z.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5emxpohoo67f8arq6i62.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g26x59m5eywcxm6thotk.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pa1jlozwcoilh5xey2yj.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kietxcv7zmys5jbd8ja0.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gc29vdhn8teimviflw2z.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pfrus8quqd2aqvbz4qhr.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b73z5j1gv3keyvyc18tm.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l1z72uugcf19webzbqow.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a1xxadoigt3kkwx9j2g7.png)

##Phase 2: Enable Block Public Access Option in S3 Bucket for Compliance Purpose
1. Open the S3 console and enable the block public access option in s3 bucket. Rules created for s3 will be compliant.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z9iu0sllhkxax9x6plml.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vs8x99dup9dbejdw8pz4.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zl4bcuw0q78h1dkj4u12.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/75bo4721l0rtkg9w0qml.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6xvrbzf6pymrlovot71e.png)

#Clean-up
Delete EC2 Instance, S3 Bucket and Config Rules.

#Pricing
I review the pricing and estimated cost of this example. 

Cost of EC2 Instance = $0.09

Cost of S3 = $0.01

Cost of AWS Config = $0.005

Total Cost = $(0.09 + 0.01 + 0.005) = $0.105

#Summary
In this post, I showed “how to do compliance check for ec2 and s3 using aws config”.

For more details on AWS Config, Checkout Get started AWS Config, open the [AWS Config console](https://us-east-1.console.aws.amazon.com/config/home?region=us-east-1#/dashboard). To learn more, read the [AWS Config documentation](https://docs.aws.amazon.com/config/?icmpid=docs_homepage_mgmtgov).

Thanks for reading!

Connect with me: [Linkedin](https://www.linkedin.com/in/gargee-bhatnagar-6b7223114)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/38sdi4nsp89fnui8h7dk.png)