1.12.1 • Published 8 months ago

@asimovbio/pulumi-gcp-components v1.12.1

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

pulumi-gcp-components

codecov

This package offers a set of Pulumi extended features towards the GCP classic provider.

Installing

yarn add @asimovbio/pulumi-gcp-components

Usage

Naming

Naming is a module with a few functions to create a standard naming convention for Pulumi resources.

From config: namingFromConfig

// index.ts
import * as aws from '@pulumi/aws';
import { namingFromConfig as n } from '@asimovbio/pulumi-gcp-components';

const bucket = new aws.s3.Bucket(n('icon-bucket')); // main-icon-bucket-dev
# Pulumi.dev.yaml
config:
  aws:region: us-east-1
  naming:radical: main
  naming:suffix: dev

Advanced Usage

// index.ts
import * as gcp from '@pulumi/gcp';
import { naming } from '@asimovbio/pulumi-gcp-components';

const bucketResourceName = naming(
  {
    radical: 'main',
    suffix: 'dev',
  },
  'icon-bucket'
);

const bucket = new gcp.storage.Bucket(bucketName); // main-icon-bucket-dev

Factory: createNaming

// index.ts
import * as gcp from '@pulumi/aws';
import { createNaming } from '@asimovbio/pulumi-gcp-components';

const naming = createNaming({
  radical: 'main',
  suffix: 'dev',
});

const bucket = new aws.s3.Bucket(naming('icon-bucket')); // main-icon-bucket-dev

Naming structure

<radical>-<resource-name>-<suffix>

  • radical: project name is a common usage
  • resource-name: required if more than one resource of the same type is created
  • suffix: environment name is a common usage

Options

  • radical: define radical part of name (default: pulumi.getProject())
  • suffix: define suffix part of name (default: undefined)
  • defaultSuffix: use pulumi.getStack() in suffix part of name (default: false)

EnabledGCPServices

Enables a list of services on a given GCP project. You can find the service list using:

gcloud service list

In order to list which services are enabled for a given project:

gcloud services list --enabled --project my-project

The --project parameter is not needed if you have the project set as default with gcloud config set project my-project.

To enable a list of services on a given project:

import { EnabledGCPServices } from '@asimovbio/pulumi-gcp-components';

const enabled = new EnabledGCPServices('test', {
  projectName: 'dummy',
  servicesToEnable: [
    'container.googleapis.com',
    'logging.googleapis.com',
    'monitoring.googleapis.com',
  ],
});

ServiceAccount

This component wraps up GCP's ServiceAccounts, Keys and IAMBindings altogether. The main use case is to create a service account with an access key and the needed permissions:

import { naming as n } from '@asimovbio/pulumi-gcp-components';
import { ProjectServiceAccount } from '@asimovbio/pulumi-gcp-components';

const serviceAccount = new ProjectServiceAccount(n(), {
  displayName: `My Deploy Key`,
  projectName: hierarchy.project.name, // used by default on IAM bindings
  roles: [
    'roles/compute.viewer',
    'roles/pubsub.admin',
    { id: 'roles/dns.admin', project: 'other-project' }, // you can specify a different project to IAM bindings.
  ],
  saId: n('deploy'),
});

HierarchicalBindings

This components makes it easier to create folders and projects following the GCP Resource Hierarchy. The default constructor creates a folder with a nested project:

import { HierarchicalBindings } from '@asimovbio/pulumi-gcp-components';

const hierarchy = new HierarchicalBindings('default-folder', {
  orgDomain: 'asimov.io',
  projectId: 'my-project',
  billingAccountId: config.requireSecret('billingAccountId'),
});

The Billing Account Id is optional, but bear in mind that you'll need one associated to a project in order to activate and use most of the GCP services.

1.12.1

8 months ago

1.12.0

8 months ago

1.9.9

10 months ago

1.9.8

10 months ago

1.9.7

10 months ago

1.9.6

10 months ago

1.9.5

10 months ago

1.11.0

9 months ago

1.11.2

8 months ago

1.11.1

9 months ago

1.10.0

9 months ago

1.9.4

12 months ago

1.9.3

12 months ago

1.9.1

1 year ago

1.8.2

1 year ago

1.9.0

1 year ago

1.8.1

1 year ago

1.8.0

1 year ago

1.8.9

1 year ago

1.8.8

1 year ago

1.8.7

1 year ago

1.8.6

1 year ago

1.8.5

1 year ago

1.8.4

1 year ago

1.9.2

1 year ago

1.8.3

1 year ago

1.7.0

2 years ago

1.6.1

2 years ago

1.5.2

2 years ago

1.6.0

2 years ago

1.5.1

2 years ago

1.4.2

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.3.6

2 years ago

1.3.5

2 years ago

1.3.4

2 years ago

1.3.3

2 years ago

1.2.13

2 years ago

1.2.12

2 years ago

1.2.11

2 years ago

1.2.10

2 years ago

1.2.9

2 years ago

1.2.8

2 years ago

1.2.6

2 years ago

1.2.5

2 years ago

1.2.4

2 years ago

1.2.3

2 years ago

1.0.0

2 years ago