591ef7495b
And AWS CodePipeline question.
1.9 KiB
1.9 KiB
Basic CI with S3
Objectives
- Create a new S3 bucket
- Add to the bucket index.html file and make it a static website
- Create a GitHub repo and put the index.html there
- Make sure to connect your AWS account to GitHub
- Create a CI pipeline in AWS to publish the updated index.html from GitHub every time someone makes a change to the repo, to a specific branch
Solution
Manual
Create S3 bucket
- Go to S3 service in AWS console
- Insert bucket name and choose region
- Uncheck "block public access" to make it public
- Click on "Create bucket"
Static website hosting
- Navigate to the newly created bucket and click on "properties" tab
- Click on "Edit" in "Static Website Hosting" section
- Check "Enable" for "Static web hosting"
- Set "index.html" as index document and "error.html" as error document.
S3 bucket permissions
- Click on "Permissions" tab in the newly created S3 bucket
- Click on Bucket Policy -> Edit -> Policy Generator. Click on "Generate Policy" for "GetObject"
- Copy the generated policy and go to Permissions tab and replace it with the current policy
GitHub Source
- Go to Developers Tools Console and create a new connection (GitHub)
Create a CI pipeline
- Go to CodePipeline in AWS console
- Click on "Create Pipeline" -> Insert a pipeline name -> Click on Next
- Choose the newly created source (GitHub) under sources
- Select repository name and branch name
- Select "AWS CodeBuild" as build provider
- Select "Managed Image", "standard" runtime and "new service role"
- In deploy stage choose the newly created S3 bucket and for deploy provider choose "Amazon S3"
- Review the pipeline and click on "Create pipeline"
Test the pipeline
- Clone the project from GitHub
- Make changes to index.html and commit them (git commit -a)
- Push the new change, verify that the newly created AWS pipeline was triggered and check the content of the site