Create your First CI/CD pipeline with AWS & GitHub

Adil Shehzad
4 min readSep 1, 2022

You need the following accounts to get started

  1. GitHub/GitLab Account
  2. Amazon Web Services (AWS) Account

Forking Repository

You can fork this GitLab repository / GitHub Repository to get started.

Creating Public S3 Bucket

Now, we need to create a Public S3 Bucket. S3 Buckets are not public by default so, we need to make them public. Go to your Amazon Web Services(AWS) console and then, from the search bar, look for the S3 Service.

Now, after clicking on Create Bucket, you need to add the bucket name which should be unique, and the region where you want to deploy the s3 bucket, enabling ACL, which means which AWS accounts or groups should be granted access and what type of access should be granted. So Enable the ACL option and limited it to Bucket owner preferred options. Now we need to make the bucket public, so uncheck the Block Public access, go with thedefault settings for encryption, and tags, and then click on create a bucket.

Once the bucket is created, now we need to enable the Static web page on the s3 bucket for this, go to the s3 bucket you created earlier and then go to the properties option, and from the top down select the static website option.

Now, to make the bucket public, we need to add a bucket policy. You can use this bucket policy

{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1405592139000",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::<your bucket>/*"
}
]
}

Or you can also use the AWS Policy Generator.

Creating CI/CD Pipeline

Now, we need to create a pipeline, for software development, for this go to your AWS Console, from Services go to Developer Tools, and then select the AWS Code pipeline.

Click on create a pipeline, then give your pipeline a name, and click on next.

Now you need to connect with the Source, so I will connect my GitHub Account with the AWS Code pipeline.

Once the connection is completed, you can search for the Repository and then select the branch, you are using, i.e., the main branch.

Add build stage

Now you need to provide the build stage in the next step, you have Jenkins or AWS Code Build option, so select the AWS Code Build Option.

Now, we need to create a project in the AWS Code Build.

The environment image will be the managed image, the operating system is Ubuntu, the Runtime will be standard, the image is aws/code build/standard:5.0, the image version is always the latest, and the environment type is Linux. Then select New service role.

Add deploy stage

For Deploy Provider, select Amazon S3 and then select your bucket. Once selected, click Next.

Review your code pipeline and then click on create code pipeline. Now you need to wait until the build will be completed.

Conclusion :

That's all folks! You created your first CI/CD, now when you make changes to your GitHub repository, the Code pipeline will detect them and deploy new release changes to S3 Bucket. Let me know if you have any questions at https://www.linkedin.com/in/adilshehzad7/

and if you are new to DevOps then you can use this repository to get started

--

--