-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add integration tests for remaining resources
This adds integration tests for the remaining construct libraries. Also adds mapping for one missing CCAPI resource (`AWS::Events::EventBusPolicy`) re #183
- Loading branch information
Showing
13 changed files
with
404 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
name: pulumi-aws-misc | ||
runtime: nodejs | ||
description: misc integration test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import * as events from 'aws-cdk-lib/aws-events'; | ||
import * as lambda from 'aws-cdk-lib/aws-lambda'; | ||
import * as iam from 'aws-cdk-lib/aws-iam'; | ||
import * as ssm from 'aws-cdk-lib/aws-ssm'; | ||
import * as ecr from 'aws-cdk-lib/aws-ecr'; | ||
import * as cloudwatch from 'aws-cdk-lib/aws-cloudwatch'; | ||
import * as pulumicdk from '@pulumi/cdk'; | ||
import { SecretValue } from 'aws-cdk-lib'; | ||
import { AwsCliLayer } from 'aws-cdk-lib/lambda-layer-awscli'; | ||
|
||
class MiscServicesStack extends pulumicdk.Stack { | ||
constructor(app: pulumicdk.App, id: string, options?: pulumicdk.StackOptions) { | ||
super(app, id, options); | ||
const repo = new ecr.Repository(this, 'testrepo'); | ||
repo.grantPull(new iam.ServicePrincipal('lambda.amazonaws.com')); | ||
|
||
new ssm.StringParameter(this, 'testparam', { | ||
stringValue: 'testvalue', | ||
}); | ||
|
||
const eventBus = new events.EventBus(this, 'testbus'); | ||
eventBus.addToResourcePolicy( | ||
new iam.PolicyStatement({ | ||
sid: 'testsid', | ||
actions: ['events:PutEvents'], | ||
principals: [new iam.AccountRootPrincipal()], | ||
resources: [eventBus.eventBusArn], | ||
}), | ||
); | ||
|
||
// This type of event bus policy is created for cross account access | ||
new events.CfnEventBusPolicy(this, 'bus-policy', { | ||
action: 'events:PutEvents', | ||
statementId: 'statement-id', | ||
principal: new iam.AccountRootPrincipal().accountId, | ||
}); | ||
const connection = new events.Connection(this, 'testconn', { | ||
authorization: events.Authorization.basic('user', SecretValue.unsafePlainText('password')), | ||
}); | ||
new events.ApiDestination(this, ' testdest', { | ||
endpoint: 'https://example.com', | ||
connection, | ||
}); | ||
|
||
const fn = new lambda.Function(this, 'testfn', { | ||
runtime: lambda.Runtime.PYTHON_3_12, | ||
handler: 'index.handler', | ||
code: lambda.Code.fromInline('def handler(event, context): return {}'), | ||
}); | ||
fn.addLayers(new AwsCliLayer(this, 'testlayer')); | ||
|
||
const errors = fn.metricErrors(); | ||
const throttles = fn.metricThrottles(); | ||
const throttleAlarm = throttles.createAlarm(this, 'alarm-throttles', { threshold: 1, evaluationPeriods: 1 }); | ||
const errorsAlarm = errors.createAlarm(this, 'alarm-errors', { threshold: 1, evaluationPeriods: 1 }); | ||
const alarmRule = cloudwatch.AlarmRule.anyOf(throttleAlarm, errorsAlarm); | ||
new cloudwatch.CompositeAlarm(this, 'compositealarm', { | ||
alarmRule, | ||
}); | ||
|
||
const dashboard = new cloudwatch.Dashboard(this, 'testdash'); | ||
dashboard.addWidgets( | ||
new cloudwatch.GraphWidget({ | ||
left: [errors], | ||
}), | ||
); | ||
|
||
new iam.User(this, 'User', { | ||
groups: [new iam.Group(this, 'Group')], | ||
managedPolicies: [ | ||
new iam.ManagedPolicy(this, 'ManagedPolicy', { | ||
statements: [ | ||
new iam.PolicyStatement({ | ||
actions: ['s3:*'], | ||
resources: ['*'], | ||
effect: iam.Effect.DENY, | ||
}), | ||
], | ||
}), | ||
], | ||
}); | ||
} | ||
} | ||
|
||
new pulumicdk.App('app', (scope: pulumicdk.App) => { | ||
new MiscServicesStack(scope, 'teststack'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.0.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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.