Loading repository data…
Loading repository data…
aws-solutions-library-samples / repository
This Guidance demonstrates how developers can build applications on mobile iOS and Apple Vision Pro in the AWS Cloud using Unity—a widely-used game engine and development platform where developers can create immersive 2D and 3D interactive experiences.
AWS blog: Implementing a Build Pipeline for Unity Mobile Apps
List the top-level sections of the README template, along with a hyperlink to the specific section.
This guidance describes architectural considerations and configuration steps for developing and building Unity-based Apple Vision Pro / iOS applications using AWS services. It demonstrates how to implement a resilient, scalable, cost efficient and secure build pipeline on AWS, leveraging services such as Amazon EC2, Amazon ECS, and Amazon S3.
The intended audience of this guidance are DevOps engineers, Cloud architects, system administrators, and platform engineers who would like to get hands-on experience architecting cloud-native applications for Apple Vision Pro / iOS in the AWS Cloud and are familiar with Unity development.
Below is an architecture diagram of the Unity build pipeline for Apple Vision Pro / iOS applications using AWS services.
Following this architecture, you should be able to:
| AWS service | Role | Description |
|---|---|---|
| Amazon EC2 | Core service | Hosts Linux and Mac instances for Unity builds and iOS compilation |
| Amazon ECS | Core service | Runs the Jenkins Controller on Fargate |
| Amazon S3 | Core service | Stores build artifacts and intermediary files |
| Amazon VPC | Core Service | Provides network isolation and security |
| Amazon Autoscaling | Core Service | Provides flexifility and cost efficiency |
| Systems Manager | Supporting service | Manages EC2 instances and provides secure access |
| NAT Gateway | Supporting service | Enables outbound internet access for private resources |
| Elastic Load Balancing | Supporting service | Provides load balancing for the Jenkins Controller |
This guidance is based on using Amazon EC2 instances to host Unity builds and iOS compilation. It leverages Amazon ECS Fargate to run the Jenkins Controller for orchestrating the build pipeline and Amazon Autoscaling to adjust solution flexibility. You can extend the solutionby using containers to build Unity images, different EC2 Linux instances to adjust assets compilation phase and different EC2 Mac instances in combination with regular capacity adjustments for optimal cost control, security and build speed.
You are responsible for the cost of the AWS services used while running this solution guidance. As of July 2024, the cost for running this guidance with the default settings in the US East (N. Virginia) Region is approximately $688 per month for processing (1000 builds). We recommend creating a Budget through AWS Cost Explorer to help manage costs. Prices are subject to change. For full details, refer to the pricing webpage for each AWS service used in this Guidance.
The following table provides a sample cost breakdown for deploying this guidance in the US East (N. Virginia) Region for one month.
| AWS service | Dimensions | Cost [USD] |
|---|---|---|
| Amazon ECS (Fargate) | 1 task running 24/7 | $36 |
| Amazon EC2 (Linux Spot) | c5.xlarge spot instances, 24/7 usage | $48 |
| Amazon EC2 (Mac) | 1 mac2.metal instance, 24/7 usage | $491 |
| Amazon S3 | 100 GB storage, 1000 PUT/COPY/POST/LIST requests | $3 |
| NAT Gateway | 2 NAT Gateways, 100 GB data processed | $70 |
| Application Load Balancer | 1GB processed bytes | $16 |
| Amazon EBS | 3x 100GB volumes, 24/7 usage | $24 |
| Amazon EFS | 1GB storage | $0.20 |
| TOTAL | estimate | $688 |
Before you begin deploying this guidance, ensure you have the following prerequisites in place:
AWS Account and Permissions
First, prepare an environment where AWS CDK can be executed. This environment must meet the following conditions:
If your environment meets the above conditions, it can be used on local terminals, AWS Cloud9, EC2 instances, etc.
Ensure you have the necessary network access to create and manage AWS resources, including VPCs, subnets, and security groups.
Verify that your AWS account has sufficient service quotas, especially for:
By ensuring these prerequisites are met, you'll be well-prepared to deploy and use this guidance effectively.
Navigate to the root directory of this prototype (the directory containing README.md) and execute the following commands. Note that all subsequent cdk commands are assumed to be executed in this root directory.
# Install Node dependencies
npm ci
# Initialize CDK for use in your AWS environment
npx cdk bootstrap
npm ci installs Node dependencies. This is only necessary the first time. cdk bootstrap performs initial setup to use CDK in your environment. This is necessary when using CDK for the first time in a particular AWS account and region. It's not needed for subsequent uses. ✅ If you see a message like "Environment aws://xxxx/ap-northeast-1 bootstrapped", it's successful. Proceed to the next step.
The AWS services used for this guidance are supported in all AWS regions where Amazon EC2 Mac instances are available. Please check the AWS Regional Services List for the most up-to-date information.
We assume that you have already built a build pipeline, but for detailed instructions on how to build it, please refer to the following link: Build Pipeline CDK Project Deployment Steps. You can deploy using AWS CDK, and it only takes a few CLI commands to deploy.
Before you deploy it, you need to set several parameters.
The Jenkins controller's initial admin password is set in jenkins.yaml.ejs. It is recommended to update the password to a sufficiently strong one (the default is passw0rd.)
users:
- id: admin
password: passw0rd
Please open bin/jenkins-unity-build.ts. There are a few parameters you can configure.
new JenkinsUnityBuildStack(app, 'JenkinsUnityBuildStack', {
env: {
region: 'us-east-2',
// account: '123456789012',
},
allowedCidrs: ['127.0.0.1/32'],
// certificateArn: "",
});
The allowedCidrs property specifies IP address ranges that can access the Jenkins web UI ALB. You should set these ranges as narrowly as possible to prevent unwanted users from accessing your Jenkins UI.
To change the AWS region (the default is us-east-2, Ohio), please replace region property.
For additional security, you can create an AWS Certificate Manager certificate, and import it by setting certificateArn and env.account in the above code to encrypt the data transferred through the ALB with TLS. By default, Jenkins Web GUI is accessed via HTTP.
After CDK bootstrapping, you are ready to deploy the CDK project by the following command:
npx cdk deploy
The first deployment should take about 15 minutes. You can also use the npx cdk deploy command to deploy when you change your CDK templates in the future.
After a successful deployment, you will get a CLI output as below:
✅ JenkinsUnityBuildStack
✨ Deployment time: 67.1s
Outputs:
JenkinsUnityBuildStack.JenkinsControllerServiceLoadBalancerDNS8A32739E = Jenki-Jenki-1234567890.us-east-2.elb.amazonaws.com
JenkinsUnityBuildStack.JenkinsControllerServiceServiceURL6DCB4BEE = http://Jenki-Jenki-1234567890.us-east-2.elb.amazonaws.com
By opening the URL in JenkinsControllerServiceServiceURL output, you can now access to Jenkins Web GUI. Please login with the username and password you entered in jenkins.yaml.ejs.
You can also configure to deploy EC2 Mac instances or a Unity accelerator instance. For further details, please refer to the document here.
To validate the deployme