npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@jjrawlins/cdk-ami-builder

v0.0.2

Published

Creates an EC2 AMI using an Image Builder Pipeline and returns the AMI ID.

Downloads

188

Readme

ImagePipeline Construct for AWS CDK

Overview

The ImagePipeline construct is a versatile and powerful component of the AWS Cloud Development Kit (CDK) designed for creating and managing AWS Image Builder pipelines. This construct simplifies the process of setting up automated pipelines for building and maintaining Amazon Machine Images (AMIs). It provides extensive customization options, enabling users to tailor the pipeline to specific needs, including vulnerability scanning, cross-account distribution, and more.

Benefits

  1. Customizable Image Building: Offers a wide range of parameters to customize the AMI, including VPC settings, security groups, instance types, and more.
  2. Automated Pipeline Management: Automates the pipeline creation and execution process, reducing manual effort and potential errors.
  3. Cross-Account AMI Distribution: Facilitates the copying of AMIs to multiple AWS accounts, enhancing resource sharing and collaboration.
  4. Vulnerability Scanning Integration: Supports integration with AWS Inspector for continuous vulnerability scanning, ensuring security compliance.
  5. User-Friendly: Designed with user experience in mind, making it easy to integrate into AWS CDK projects.
  6. Scalability and Flexibility: Scales according to your needs and provides flexibility in configuring various aspects of the image building process.

Prerequisites

  • AWS account and AWS CLI configured.
  • Familiarity with AWS CDK and TypeScript.
  • Node.js and npm installed.

Installation

Ensure that you have the AWS CDK installed. If not, you can install it using npm:

npm install -g aws-cdk

Next, add the ImagePipeline construct to your CDK project:

npm install '@layerborn/cdk-ami-builder' --save

Usage Example

Below is an example of how to use the ImagePipeline construct in your CDK application.

Importing the Construct

First, import the ImagePipeline construct into your CDK application:

import { ImagePipeline } from '@layerborn/cdk-ami-builder';

Using the Construct

Here's an example of how to use the ImagePipeline construct:

const vpc = new Vpc(this, 'Vpc', {
    ipAddresses: IpAddresses.cidr(props.vpcCidr as string),
    maxAzs: 2,
    subnetConfiguration: [
        {
            name: 'Public',
            subnetType: SubnetType.PUBLIC,
            cidrMask: 24,
        },
        {
            name: 'Private',
            subnetType: SubnetType.PRIVATE_WITH_EGRESS,
            cidrMask: 24,
        },
    ],
    natGateways: 1,
});

const image = ec2.MachineImage.lookup({
    name: 'ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-*',
    owners: ['099720109477'],
});

const version = process.env.IMAGE_VERSION_NUMBER ?? '0.0.8';

const imagePipeline = new ImagePipeline(this, 'ImagePipeline', {
    parentImage: image.getImage(this).imageId,
    vpc: vpc,
    imageRecipeVersion: version,
    autoBuild: true, // Otherwise you can't use the below output
    components: [
        {
            name: 'Install-Monitoring',
            platform: 'Linux',
            componentDocument: {
                phases: [{
                    name: 'build',
                    steps: [
                        {
                            name: 'Install-CloudWatch-Agent',
                            action: 'ExecuteBash',
                            inputs: {
                                commands: [
                                    'apt-get update',
                                    'DEBIAN_FRONTEND=noninteractive apt-get install -y g++ make cmake unzip libcur14-openssl-dev',
                                    'DEBIAN_FRONTEND=noninteractive apt-get install -y curl sudo jq bash zip unzip iptables software-properties-common ca-certificates',
                                    'curl -sfLo /tmp/amazon-cloudwatch-agent.deb https://s3.amazonaws.com/amazoncloudwatch-agent/ubuntu/amd64/latest/amazon-cloudwatch-agent.deb',
                                    'dpkg -i -E /tmp/amazon-cloudwatch-agent.deb',
                                    'rm /tmp/amazon-cloudwatch-agent.deb',
                                ],
                            },
                        },
                    ],
                }],
            },
        },
    ],
});

new CfnOutput(this, `ImageId-${this.stackName}`, {
    value: imagePipeline.imageId,  // Only valid if autoBuild=true
    description: 'The AMI ID of the image created by the pipeline',
});

This example demonstrates creating a new VPC and setting up an Image Pipeline within it. You can customize the `

ImagePipeline` properties according to your requirements.

Customization Options

  • vpc: Specify the VPC where the Image Pipeline will be deployed.
  • parentImage: Define the base AMI for the image recipe.
  • components: List custom components for the AMI, such as software installations and configurations.
  • Additional properties like imageRecipeVersion, platform, enableVulnScans, etc., allow further customization.

Outputs

The construct provides outputs like imagePipelineArn and imageId, which can be used in other parts of your AWS infrastructure setup.

Best Practices

  1. Parameter Validation: Ensure that all inputs to the construct are validated.
  2. Security: Follow best practices for security group and IAM role configurations.
  3. Resource Naming: Use meaningful names for resources for better manageability.
  4. Error Handling: Implement error handling for pipeline execution and custom resources.

Support and Contribution

For support, please contact the package maintainer or open an issue in the repository. Contributions to the package are welcome. Please follow the contribution guidelines in the repository.


This README provides a basic guide to getting started with the ImagePipeline construct. For more advanced usage and customization, refer to the detailed documentation in the package.

User