This cdk IaC library helps you to deploy AWS cloud infrastructure to allow embedded Linux builds for your project.
API documentation generated by npm run doc
In order to use this library, you must set up the CDK, including installing the CDK tool and bootstrapping the account you wish to deploy to. Additionally, you must have Node installed.
Note
This library is tested against Node Versions 16, 18, and 20. If these versions are not available for your system, we recommend using NVM to install a compatible version
Use the examples in our examples repo.
- Create a CDK project. More details can be found in the CDK Getting Started Documentation.
mkdir my-project cd my-project cdk init app --language typescript
- Add the cdk library with
npm install aws4embeddedlinux/aws4embeddedlinux-ci
. - Create your application using the library. Refer to the API Documentation and the Examples for more details.
- Deploy your application using
cdk deploy
. - After the application is deployed, the 'Build Image' Pipeline needs to be run. This will create an Ubuntu based container for building Yocto. This container is used by the other pipelines. If the other pipelines are run before this container is created and pushed to ECR, they will fail. This Build Image Pipeline will run weekly by default to keep this container patched.
- Now the application pipeline can be run. This will push the contents of the Yocto deploy directory into S3.
The cdk diff
command can be used to preview changes before deployment. This will allow the user to review what is being created.
You can use npm link
to develop with a local copy of this repo.
npm install
npm install
npm link ../aws4embeddedlinux-ci
This will link through the system node_modules
install. When using a system node install on Linux, this can require sudo access. To avoid this, use
a node version manager
or set a node prefix.
- Windows is currently not supported.
- When using AWS Cloud9 a micro instance type will run out of memory.
- Deletion of stacks while a CodePipeline is running can lead to unexpected failures.
See SECURITY for more information about reporting issues with this project.
AWS Secrets Manager is the preferred method of adding secrets to your pipeline. This service provides a structured means of access and avoids the pitfalls of putting secrets in environment variables, source repos, etc.
- Create a Secret in Secrets Manager and add your secret value.
- Grant access permissions to the CodeBuild pipeline project.
- Create a Policy Statement which allows
secretsmanager:GetSecretValue
for your secret. - Add this policy statement to the
buildPolicyAdditions
props for theEmbeddedLinuxPipelineStack
. e.g.
import * as iam from "aws-cdk-lib/aws-iam";
const pipeline = new EmbeddedLinuxPipelineStack(app, "MyPokyPipeline", {
imageRepo: buildImageRepo.repository,
imageTag: ImageKind.Ubuntu22_04,
vpc: vpc.vpc,
buildPolicyAdditions: [
iam.PolicyStatement.fromJson({
Effect: "Allow",
Action: "secretsmanager:GetSecretValue",
Resource:
"arn:aws:secretsmanager:us-west-2:123456789012:secret:my-secret-??????",
}),
],
});
The secret can then be used in the CodeBuild Project by adding it to the BuildSpec. See the CodeBuild Documentation for more details.
env:
secrets-manager:
SECRET_VALUE: "<Secret ARN>"
CVE checking is enabled in the reference implementations. Details on this can be found in the yocto documentation.
See CONTRIBUTING for more information.
This library is licensed under the MIT-0 License. See the LICENSE file.