Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/providers/aws/pulumi/base-image-snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class CloudyPadAwsBaseImage extends pulumi.ComponentResource {
super("crafteo:cloudypad:aws:base-image", name, args, opts)

const globalTags = pulumi.all([args.additionalTags]).apply(([tags]) => [
name,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was creating tags like myinstance=myinstance 🫠

...tags
])

Expand Down Expand Up @@ -166,7 +165,7 @@ export class AwsBaseImagePulumiClient extends InstancePulumiClient<PulumiStackCo

const stack = await this.getStack()
await stack.setConfig("aws:region", { value: config.region})
await stack.setConfig("additionalTags", { value: JSON.stringify([`instance:${config.instanceName}`])})

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know you run a SaaS for CloudyPad. You might have stuff which assumes instance tags exist. If so, we can always keep this tag as-is.

await stack.setConfig("additionalTags", { value: JSON.stringify([`CloudyPadInstance:${config.instanceName}`, `DeployedBy:cloudypad`])})
if(config.rootVolumeId) await stack.setConfig("rootVolumeId", { value: config.rootVolumeId})

const allConfs = await stack.getAllConfig()
Expand Down
3 changes: 1 addition & 2 deletions src/providers/aws/pulumi/data-volume-snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class CloudyPadAwsDataDiskSnapshot extends pulumi.ComponentResource {
super("crafteo:cloudypad:aws:data-disk-snapshot", name, args, opts)

const globalTags = pulumi.all([args.additionalTags]).apply(([tags]) => [
name,
...tags
])

Expand Down Expand Up @@ -120,7 +119,7 @@ export class AwsDataDiskSnapshotPulumiClient extends InstancePulumiClient<Pulumi

const stack = await this.getStack()
await stack.setConfig("aws:region", { value: config.region})
await stack.setConfig("additionalTags", { value: JSON.stringify([`instance:${config.instanceName}`])})
await stack.setConfig("additionalTags", { value: JSON.stringify([`CloudyPadInstance:${config.instanceName}`, `DeployedBy:cloudypad`])})
await stack.setConfig("volumeId", { value: config.baseVolumeId})

const allConfs = await stack.getAllConfig()
Expand Down
13 changes: 10 additions & 3 deletions src/providers/aws/pulumi/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ class CloudyPadEC2Instance extends pulumi.ComponentResource {
} else if (args.publicKeyContent){
this.keyPair = new aws.ec2.KeyPair(`${name}-keypair`, {
publicKey: args.publicKeyContent,
keyName: awsResourceNamePrefix
keyName: awsResourceNamePrefix,
tags: globalTags,
}, {
...commonPulumiOpts,
ignoreChanges: args.ignorePublicKeyChanges ? [ "publicKey" ] : []
Expand Down Expand Up @@ -180,7 +181,7 @@ class CloudyPadEC2Instance extends pulumi.ComponentResource {
...args.tags,
Name: awsResourceNamePrefix
},
volumeTags: args.tags,
volumeTags: { ...args.tags, Name: `${awsResourceNamePrefix}-os` },
vpcSecurityGroupIds: [this.securityGroup.id],
keyName: this.keyPairName,
rootBlockDevice: {
Expand Down Expand Up @@ -213,7 +214,7 @@ class CloudyPadEC2Instance extends pulumi.ComponentResource {
size: args.dataDisk.sizeGb,
type: "gp3",
availabilityZone: this.ec2Instance.availabilityZone,
tags: globalTags,
tags: { ...globalTags, Name: `${awsResourceNamePrefix}-data` },
snapshotId: args.dataDisk.snapshotId,
}, {
...commonPulumiOpts,
Expand Down Expand Up @@ -310,6 +311,11 @@ async function awsPulumiProgram(): Promise<Record<string, any> | void> {

const instanceName = pulumi.getStack()

const cloudypadTags = {
DeployedBy: "cloudypad",
CloudyPadInstance: instanceName,
}

// Use provided imageId if available, otherwise use default Ubuntu AMI
const amiId = imageId ? pulumi.output(imageId) : aws.ec2.getAmiOutput({
mostRecent: true,
Expand Down Expand Up @@ -350,6 +356,7 @@ async function awsPulumiProgram(): Promise<Record<string, any> | void> {
}

const instance = new CloudyPadEC2Instance(instanceName, {
tags: cloudypadTags,
ami: amiId,
type: instanceType,
availabilityZone: zone,
Expand Down