A 04
A 04
A 04
A 04
Due Oct 17 by 3pm
Points 10
Submitting a file upload
File Types zip
Attempts 1
Allowed Attempts 3
Available Oct 10 at 9:40pm - Oct 17 at 3pm
This assignment was locked Oct 17 at 3pm.
Learning Objectives
The objective of this assignment is to learn how to build custom machine images with our application
and dependencies baked in.
1. Use Ubuntu 24.04 LTS as your source image to create a custom image using Packer.
2. All custom images you build should be private. Only you can launch instances from it.
3. All custom image builds should happen in your DEV AWS account.
4. Custom image builds should be set up to run in your default VPC.
5. The custom image should include everything needed to run your application and the application
binary itself. For e.g., if you are using Tomcat to run your Java web application, your custom
image must have Java & Tomcat installed. You should also ensure the Tomcat service starts when
an instance is launched. If you are using Python, make sure you have the right version of Python
and that the libraries you need are installed in the custom image.
6. The packer template should be stored in the same repo as the web application.
7. For this assignment only, install MySQL/MariaDB/PostgreSQL locally in the custom image.
https://northeastern.instructure.com/courses/192916/assignments/2473742 Page 1 of 7
A 04 10/27/24, 12:57
1. Run the packer fmt command. If this command modifies the packer template, the workflow
should fail and prevent users from merging the pull request.
2. Run the packer validate command. If this command fails to validate the packer template, the
workflow should fail, and users should be prevented from merging the pull request.
Setup
1. You will need to create a new IAM service account (manually in AWS console) in the DEV AWS
for GitHub Actions and configure the security credentials in your organization repository. Refer
to this (https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions) for
more details.
2. Grant the service account the roles needed. See documentation
(https://github.com/hashicorp/packer-plugin-googlecompute/blob/main/docs/README.md#running-
on-google-cloud) for more details.
3. Install & configure on your GitHub Actions runner with this
AWS cli (https://github.com/aws-
actions/configure-aws-credentials) marketplace action.
When a pull request is merged, this GitHub Actions workflow should be triggered to do the
following:
https://northeastern.instructure.com/courses/192916/assignments/2473742 Page 2 of 7
A 04 10/27/24, 12:57
1. Create a local user csye6225 with the primary group csye6225 . This user should not have a
login shell, i.e. login shell should be /usr/sbin/nologin .
See https://www.baeldung.com/linux/create-non-login-user
(https://www.baeldung.com/linux/create-non-login-user) for details.
2. Install application dependencies and set up the application by copying the application artifacts
and the configuration files.
3. The application artifacts, configuration, etc., must be owned by the user csye6225 and
group csye6225 .
4. Add your systemd service file to /etc/systemd/system and configure it to start your service
when the instance is launched.
1. Run systemctl daemon-reload with sudo
2. Run systemtl enable <service_name> with sudo
4. No custom image should be built if any of the jobs or steps in the workflow fail.
EC2 Instance
Create an EC2 instance with the following specifications. You may go with default values for any
parameter not provided in the table below. The EC2 instance must be launched in the VPC created
by Terraform. You cannot launch the EC2 instance in the default VPC.
https://northeastern.instructure.com/courses/192916/assignments/2473742 Page 3 of 7
A 04 10/27/24, 12:57
Submission
1. Create a folder with the naming convention firstname_lastname_neuid_## where ## is the
assignment number.
2. Clone each (all) repository you have created for the course using git clone command into this
directory. It is important that you clone your Organization repository and not your fork.
3. Create a zip of the firstname_lastname_neuid_## directory. The zip file should
be firstname_lastname_neuid_##.zip .
4. Now unzip the zip file in some other directory and confirm the content of the zip files.
5. Upload the Zip to the correct assignment in Canvas.
6. You are allowed to resubmit. If you think the ZIP file may have an issue, please submit it again.
Only the latest submission will be graded.
Grading Guidelines
Warning: The following guidelines are for information only and are subject to change at the discretion
of the instructor and TA.
Security
1. Committing any kind of credentials to the code or uploading them as part of your Canvas
https://northeastern.instructure.com/courses/192916/assignments/2473742 Page 4 of 7
A 04 10/27/24, 12:57
https://northeastern.instructure.com/courses/192916/assignments/2473742 Page 5 of 7
A 04 10/27/24, 12:57
1. No direct commits are made to the organization repository. Verify that the student works from a
forked repository and uses the feature branch. There should be no direct commits to the main
branch in their forked repository.
IAM (8%)
1. The student has created a separate IAM user for GitHub Actions in their DEV account.
2. This user has a custom IAM policy
(https://developer.hashicorp.com/packer/integrations/hashicorp/amazon#iam-task-or-instance-role)
attached to them.
3. This IAM user does not have admin access to the AWS account.
4. This IAM user does not have console access.
5. This IAM user only has programmatic access to the account.
https://northeastern.instructure.com/courses/192916/assignments/2473742 Page 6 of 7
A 04 10/27/24, 12:57
https://northeastern.instructure.com/courses/192916/assignments/2473742 Page 7 of 7