Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft pulumi-cdk 1.0 blog #13434

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Draft pulumi-cdk 1.0 blog #13434

wants to merge 6 commits into from

Conversation

mjeffryes
Copy link
Member

@mjeffryes mjeffryes commented Nov 25, 2024

Announcement blog for Pulumi CDK version 1.0

There are a few TODOs:

  • meta image
  • testing the examples (Most are coppied from the README and should be tested already, but example with cloudfront integration needs closer review)

Resolves: pulumi/pulumi-cdk#249

Comment on lines +120 to +178
```typescript
import * as pulumicdk from '@pulumi/cdk';
import * as aws from '@pulumi/aws';

const app = new pulumicdk.App('app', (scope: pulumicdk.App): pulumicdk.AppOutputs => {
const stack = new pulumicdk.Stack('example-stack');
// use getAmiOutput to lookup the AMI instead of ec2.LookupMachineImage
const ami = aws.ec2.getAmiOutput({
owners: ['amazon'],
mostRecent: true,
filters: [
{
name: 'name',
values: ['al2023-ami-2023.*.*.*.*-arm64'],
},
],
});

const region = aws.config.requireRegion();
const machineImage = ec2.MachineImage.genericLinux({
[region]: pulumicdk.asString(ami.imageId),
});

const instance = new ec2.Instance(this, 'Instance', {
vpc,
instanceType: ec2.InstanceType.of(ec2.InstanceClass.T4G, ec2.InstanceSize.MICRO),
machineImage,
});

// Return the public IP of the instance
this.publicIp = this.asOutput(ec2Instance.publicIp);
});

// Pulumi's abstraction to create a CloudFront distribution
const distribution = new aws.cloudfront.Distribution("my-cdn-distribution", {
enabled: true,
origins: [{
originId: ec2Instance.urn,
domainName: ec2PublicIp.apply(ip => `${app.publicIp}.compute-1.amazonaws.com`), // Constructed domain name
customOriginConfig: {
originProtocolPolicy: "http-only",
httpPort: 80,
httpsPort: 80,
originSslProtocols: ["TLSv1.2"],
},
}],
defaultCacheBehavior: {
targetOriginId: ec2Instance.urn,
viewerProtocolPolicy: "allow-all",
allowedMethods: ["GET", "HEAD", "OPTIONS"],
cachedMethods: ["GET", "HEAD"],
// Define cache behavior settings...
},
// Additional settings like price class, custom error responses, etc.
// ...
viewerCertificate: {
cloudfrontDefaultCertificate: true,
},
});
Copy link
Member Author

@mjeffryes mjeffryes Nov 25, 2024

Choose a reason for hiding this comment

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

@corymhall I would appreciate your sanity check on this I smashed some examples together based on our conversation Friday about the most compelling features from a CDK users perspective, but it probably needs some fixes.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think a cool one here would be to replace CloudFront with CloudFlare to highlight the cross cloud ability.

I started working on an example of that, but I don't know if it would be deployable without an existing CloudFlare domain which I'm not sure we have.

Copy link
Member Author

Choose a reason for hiding this comment

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

🤦 I had intended to use Cloudflare, but was moving quickly and asked the AI the wrong question. We do have an example creating a record on cloudflare so I think we could test with that account+domain: pulumi-cloudflare/examples/record/ts/index.ts at master · pulumi/pulumi-cloudflare

Copy link
Contributor

Choose a reason for hiding this comment

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

I created a draft PR with an example. I can't get it to work though so there must be something wrong with the integration (maybe the domain is not public)

pulumi/pulumi-cdk#260

content/blog/aws-cdk-on-pulumi-1.0/index.md Outdated Show resolved Hide resolved
content/blog/aws-cdk-on-pulumi-1.0/index.md Show resolved Hide resolved
Comment on lines +120 to +178
```typescript
import * as pulumicdk from '@pulumi/cdk';
import * as aws from '@pulumi/aws';

const app = new pulumicdk.App('app', (scope: pulumicdk.App): pulumicdk.AppOutputs => {
const stack = new pulumicdk.Stack('example-stack');
// use getAmiOutput to lookup the AMI instead of ec2.LookupMachineImage
const ami = aws.ec2.getAmiOutput({
owners: ['amazon'],
mostRecent: true,
filters: [
{
name: 'name',
values: ['al2023-ami-2023.*.*.*.*-arm64'],
},
],
});

const region = aws.config.requireRegion();
const machineImage = ec2.MachineImage.genericLinux({
[region]: pulumicdk.asString(ami.imageId),
});

const instance = new ec2.Instance(this, 'Instance', {
vpc,
instanceType: ec2.InstanceType.of(ec2.InstanceClass.T4G, ec2.InstanceSize.MICRO),
machineImage,
});

// Return the public IP of the instance
this.publicIp = this.asOutput(ec2Instance.publicIp);
});

// Pulumi's abstraction to create a CloudFront distribution
const distribution = new aws.cloudfront.Distribution("my-cdn-distribution", {
enabled: true,
origins: [{
originId: ec2Instance.urn,
domainName: ec2PublicIp.apply(ip => `${app.publicIp}.compute-1.amazonaws.com`), // Constructed domain name
customOriginConfig: {
originProtocolPolicy: "http-only",
httpPort: 80,
httpsPort: 80,
originSslProtocols: ["TLSv1.2"],
},
}],
defaultCacheBehavior: {
targetOriginId: ec2Instance.urn,
viewerProtocolPolicy: "allow-all",
allowedMethods: ["GET", "HEAD", "OPTIONS"],
cachedMethods: ["GET", "HEAD"],
// Define cache behavior settings...
},
// Additional settings like price class, custom error responses, etc.
// ...
viewerCertificate: {
cloudfrontDefaultCertificate: true,
},
});
Copy link
Contributor

Choose a reason for hiding this comment

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

I think a cool one here would be to replace CloudFront with CloudFlare to highlight the cross cloud ability.

I started working on an example of that, but I don't know if it would be deployable without an existing CloudFlare domain which I'm not sure we have.

content/blog/aws-cdk-on-pulumi-1.0/index.md Outdated Show resolved Hide resolved

Currently AWS CDK on Pulumi is supported only for TypeScript users, but we're eager to bring the benefits of the CDK ecosystem to all Pulumi languages in the future. In the meantime, AWS CDK on Pulumi can be used within Component Packages implemented in TypeScript, and exposed to any Pulumi language.

We're also exploring options for importing state from CDK applications that are already deployed with CloudFormation to enable seamless migration for existing CDK users. Please let us know if this is something you would be interested in in testing with us.
Copy link
Contributor

Choose a reason for hiding this comment

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

I was talking with @t0yv0 and thought it might be cool to publish the tool as experimental alpha so at least we can point users somewhere.

Copy link
Member Author

Choose a reason for hiding this comment

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

I would support that. based on who was interested in CDK support, I imagine this migration tool is going to be in high demand

@pulumi-bot
Copy link
Collaborator

@mjeffryes mjeffryes self-assigned this Nov 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pulumi-cdk 1.0 Blog post
4 participants