Make an aws/cloudformation module
This includes the original CloudFormation resource type in addition to the various tag helpers.
This commit is contained in:
parent
d10f2e6bff
commit
c7f0465c41
5 changed files with 59 additions and 9 deletions
1
lib/aws/.gitignore
vendored
1
lib/aws/.gitignore
vendored
|
@ -1,2 +1,3 @@
|
|||
bin/
|
||||
node_modules/
|
||||
|
||||
|
|
5
lib/aws/cloudformation/index.ts
Normal file
5
lib/aws/cloudformation/index.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
// Copyright 2016 Marapongo, Inc. All rights reserved.
|
||||
|
||||
export * from './resource';
|
||||
export * from './tags';
|
||||
|
|
@ -1,22 +1,22 @@
|
|||
import * as as mu from 'mu';
|
||||
// Copyright 2016 Marapongo, Inc. All rights reserved.
|
||||
|
||||
import * as mu from 'mu';
|
||||
|
||||
// A special service that simply emits a CloudFormation template.
|
||||
// @name: aws/x/cf
|
||||
export default class CloudFormation extends mu.Extension {
|
||||
constructor(ctx: mu.Context, args: CloudFormationArgs) {
|
||||
export class Resource extends mu.Extension {
|
||||
constructor(ctx: mu.Context, args: ResourceArgs) {
|
||||
super(ctx);
|
||||
// TODO: encode the special translation logic as code (maybe as an overridden method).
|
||||
}
|
||||
}
|
||||
|
||||
export interface CloudFormationArgs {
|
||||
export interface ResourceArgs {
|
||||
// The CF resource name.
|
||||
readonly resource: string;
|
||||
// An optional list of properties to map.
|
||||
readonly properties?: Map<string, string>;
|
||||
// An optional set of arbitrary key/values to merge with the mapped ones.
|
||||
readonly extraProperties?: Map<string, any>;
|
||||
readonly properties?: any /*actually, JSON-like*/;
|
||||
// An optional list of other CloudFormation resources that this depends on.
|
||||
readonly dependsOn?: mu.Stack[];
|
||||
readonly dependsOn?: string[];
|
||||
}
|
||||
|
36
lib/aws/cloudformation/tags.ts
Normal file
36
lib/aws/cloudformation/tags.ts
Normal file
|
@ -0,0 +1,36 @@
|
|||
// Copyright 2016 Marapongo, Inc. All rights reserved.
|
||||
|
||||
// Tag can be applied to a resource, helping to identify and categorize those resources.
|
||||
export interface Tag {
|
||||
// The key name of the tag. You can specify a value that is 1 to 127 Unicode characters in length and cannot be
|
||||
// prefixed with aws:. You can use any of the following characters: the set of Unicode letters, digits, whitespace,
|
||||
// _, ., /, =, +, and -.
|
||||
key: string;
|
||||
// The value for the tag. You can specify a value that is 1 to 255 Unicode characters in length and cannot be
|
||||
// prefixed with aws:. You can use any of the following characters: the set of Unicode letters, digits, whitespace,
|
||||
// _, ., /, =, +, and -.
|
||||
value: string;
|
||||
}
|
||||
|
||||
// Tags is simply a collection of Tag values.
|
||||
export type Tags = Tag[];
|
||||
|
||||
// TagArgs represents a base type for the common pattern of resources accepting tags and a name.
|
||||
export interface TagArgs {
|
||||
// An optional name for this resource.
|
||||
name?: string;
|
||||
// An arbitrary set of tags (key-value pairs) for this resource.
|
||||
tags?: Tags;
|
||||
}
|
||||
|
||||
// expandTags takes a TagArgs and expands the "Name" key in-place, for naming, when present.
|
||||
export function expandTags(args: TagArgs): void {
|
||||
if (args.name !== undefined) {
|
||||
if (args.tags == undefined) {
|
||||
args.tags = [];
|
||||
}
|
||||
args.tags.push({ key: "Name", value: args.name });
|
||||
delete args.name;
|
||||
}
|
||||
}
|
||||
|
|
@ -17,14 +17,22 @@
|
|||
},
|
||||
"files": [
|
||||
"index.ts",
|
||||
|
||||
"cloudformation/index.ts",
|
||||
"cloudformation/resource.ts",
|
||||
"cloudformation/tags.ts",
|
||||
|
||||
"ec2/index.ts",
|
||||
"ec2/internetGateway.ts",
|
||||
"ec2/route.ts",
|
||||
"ec2/routeTable.ts",
|
||||
"ec2/securityGroup.ts",
|
||||
"ec2/securityGroupEgress.ts",
|
||||
"ec2/securityGroupIngress.ts",
|
||||
"ec2/subnet.ts",
|
||||
"ec2/vpc.ts",
|
||||
"ec2/vpcGatewayAttachment.ts"
|
||||
"ec2/vpcGatewayAttachment.ts",
|
||||
"ec2/vpcPeeringConnection.ts"
|
||||
]
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue