-
Notifications
You must be signed in to change notification settings - Fork 5
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
Handle SecretsManager dynamic references #202
Changes from 2 commits
e6552b8
3eb1e0d
827ea06
8caabfe
8594245
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
name: pulumi-aws-secretsmanager | ||
runtime: nodejs | ||
description: secretsmanager integration test |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import * as aws from '@pulumi/aws'; | ||
import * as ec2 from 'aws-cdk-lib/aws-ec2'; | ||
import * as rds from 'aws-cdk-lib/aws-rds'; | ||
import * as lambda from 'aws-cdk-lib/aws-lambda'; | ||
import * as iam from 'aws-cdk-lib/aws-iam'; | ||
import * as secrets from 'aws-cdk-lib/aws-secretsmanager'; | ||
import * as pulumicdk from '@pulumi/cdk'; | ||
import { CfnOutput, SecretValue } from 'aws-cdk-lib'; | ||
|
||
class SecretsManagerStack extends pulumicdk.Stack { | ||
constructor(app: pulumicdk.App, id: string, options?: pulumicdk.StackOptions) { | ||
super(app, id, options); | ||
|
||
const vpc = new ec2.Vpc(this, 'Vpc', { | ||
maxAzs: 2, | ||
ipAddresses: ec2.IpAddresses.cidr('10.0.0.0/16'), | ||
natGateways: 0, | ||
subnetConfiguration: [ | ||
{ | ||
name: 'Isolated', | ||
subnetType: ec2.SubnetType.PRIVATE_ISOLATED, | ||
}, | ||
], | ||
}); | ||
new rds.DatabaseInstance(this, 'Instance', { | ||
vpc, | ||
engine: rds.DatabaseInstanceEngine.mysql({ | ||
version: rds.MysqlEngineVersion.VER_8_0_37, | ||
}), | ||
vpcSubnets: vpc.selectSubnets({ subnetType: ec2.SubnetType.PRIVATE_ISOLATED }), | ||
credentials: rds.Credentials.fromGeneratedSecret('admin'), | ||
}); | ||
|
||
const role = new iam.Role(this, 'Role', { | ||
assumedBy: new iam.ServicePrincipal('lambda.amazonaws.com'), | ||
}); | ||
const secret = new secrets.Secret(this, 'Secret', { | ||
description: 'A test secret', | ||
}); | ||
secret.grantRead(role); | ||
|
||
const rotationLambda = new lambda.Function(this, 'RotationLambda', { | ||
code: lambda.Code.fromInline('exports.handler = async function(event) { return event; }'), | ||
handler: 'index.handler', | ||
runtime: lambda.Runtime.NODEJS_LATEST, | ||
}); | ||
secret.addRotationSchedule('rotation', { | ||
rotationLambda, | ||
}); | ||
} | ||
} | ||
|
||
new pulumicdk.App( | ||
'app', | ||
(scope: pulumicdk.App) => { | ||
new SecretsManagerStack(scope, 'teststack'); | ||
}, | ||
{ | ||
appOptions: { | ||
remapCloudControlResource: (logicalId, typeName, props, options) => { | ||
if (typeName === 'AWS::SecretsManager::RotationSchedule') { | ||
if (props.HostedRotationLambda) { | ||
throw new Error('Hosted Rotation is not supported'); | ||
} | ||
return new aws.secretsmanager.SecretRotation( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why wouldn't we add this mapping directly to pu-cdk? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah I forgot about this. It actually should be available as a CCAPI type, but I was getting errors so I added this and forgot to go back and investigate. I'll update it. |
||
logicalId, | ||
{ | ||
secretId: props.SecretId, | ||
rotationRules: { | ||
duration: props.RotationRules.Duration, | ||
scheduleExpression: props.RotationRules.ScheduleExpression, | ||
automaticallyAfterDays: props.RotationRules.AutomaticallyAfterDays, | ||
}, | ||
rotateImmediately: props.RotateImmediatelyOnUpdate, | ||
rotationLambdaArn: props.RotationLambdaARN, | ||
}, | ||
options, | ||
); | ||
} | ||
return undefined; | ||
}, | ||
}, | ||
}, | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "pulumi-aws-cdk", | ||
"devDependencies": { | ||
"@types/node": "^10.0.0" | ||
}, | ||
"dependencies": { | ||
"@pulumi/aws": "^6.56.0", | ||
"@pulumi/aws-native": "^1.5.0", | ||
"@pulumi/cdk": "^0.5.0", | ||
"@pulumi/pulumi": "^3.0.0", | ||
"aws-cdk-lib": "2.149.0", | ||
"constructs": "10.3.0", | ||
"esbuild": "^0.24.0" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"compilerOptions": { | ||
"strict": true, | ||
"outDir": "bin", | ||
"target": "es2019", | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"sourceMap": true, | ||
"experimentalDecorators": true, | ||
"pretty": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"noImplicitReturns": true, | ||
"forceConsistentCasingInFileNames": true | ||
}, | ||
"include": [ | ||
"./*.ts" | ||
] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has this been gofmt'd? We might be missing some liner setup in the repo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this may have happened when I manually resolved merge conflicts in the github ui, but you are correct that we don't have any checks on this in CI.