Skip to content

Commit

Permalink
Job: expose codebuild project via cdk
Browse files Browse the repository at this point in the history
  • Loading branch information
fwang committed Dec 24, 2023
1 parent 28ae091 commit ceed328
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
5 changes: 5 additions & 0 deletions .changeset/chilly-elephants-shop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"sst": patch
---

Job: expose codebuild project via cdk
6 changes: 6 additions & 0 deletions packages/sst/src/constructs/Job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,12 @@ export class Job extends Construct implements SSTConstruct {
this.addEnvironmentForCodeBuild(name, value);
}

public get cdk() {
return {
codeBuildProject: this.job,
};
}

private createCodeBuildJob(): Project {
const { cdk, runtime, handler, memorySize, timeout, container } =
this.props;
Expand Down
23 changes: 6 additions & 17 deletions packages/sst/test/constructs/Job.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,23 +436,12 @@ test("sst remove", async () => {
});
});

test("bind", async () => {
const { stack, job } = await createJob();
const topic = new Topic(stack, "Topic");
const MY_TOPIC_ARN = new Config.Parameter(stack, "MY_TOPIC_ARN", {
value: topic.topicArn,
});
job.bind([MY_TOPIC_ARN]);
hasResource(stack, "AWS::CodeBuild::Project", {
Environment: {
EnvironmentVariables: arrayWith([
objectLike({ Name: "SST_Parameter_value_MY_TOPIC_ARN", Value: ANY }),
]),
},
});
test(".cdk.codeBuildProject", async () => {
const { job } = await createJob();
expect(job.cdk?.codeBuildProject.projectArn).toBeDefined();
});

test("addConfig", async () => {
test("bind()", async () => {
const { stack, job } = await createJob();
const topic = new Topic(stack, "Topic");
const MY_TOPIC_ARN = new Config.Parameter(stack, "MY_TOPIC_ARN", {
Expand All @@ -468,7 +457,7 @@ test("addConfig", async () => {
});
});

test("attachPermissions", async () => {
test("attachPermissions()", async () => {
const { stack, job } = await createJob();
const topic = new Topic(stack, "Topic");
job.attachPermissions([topic]);
Expand All @@ -479,7 +468,7 @@ test("attachPermissions", async () => {
});
});

test("addEnvironment", async () => {
test("addEnvironment()", async () => {
const { stack, job } = await createJob();
job.addEnvironment("DEBUG", "*");
hasResource(stack, "AWS::CodeBuild::Project", {
Expand Down

0 comments on commit ceed328

Please sign in to comment.