https://serverless-stack.com/ logo
#help
Title
# help
n

Neel

04/24/2022, 12:35 AM
I am trying to implement CodePipeline. And it seems it's not picking up my template.json file automatically when I try to deploy code. The PULLSOURCE & BUILDSOURCE pipeline are working just fine.
Copy code
versions_pipeline.addStage({
      stageName: "PipelineUpdate",
      actions: [
        new CloudFormationCreateUpdateStackAction({
          actionName: "PipelineUpdate",
          stackName: "PipelineStack",
          templatePath: buildOutput.atPath(
            "cdk-my-sst-app-versions-pipeline.template.json"
          ),
          adminPermissions: true,
        }),
      ],
    });
I am following a aws-cdk infra tutorial and trying it on SST. The below line is giving error.
Copy code
templatePath: buildOutput.atPath(
     "cdk-my-sst-app-versions-pipeline.template.json"
),
I guess buildOutput.atPath looks into my buildArtifact and it tries to findout my template.json. But the folderstructure is different from aws-cdk. I am not sure if I am right in saying this. The below is the error.
Copy code
File [cdk-my-sst-app-versions-pipeline.template.json] does not exist in artifact [VersionBuild]
Thanks for the help. Below is my whole PipeLineStack that I am creating. I am failing at third stage (PipelineUpdate).
Copy code
import { App, Stack, StackProps } from "@serverless-stack/resources";
import { SecretValue } from "aws-cdk-lib";
import {
  BuildSpec,
  LinuxBuildImage,
  PipelineProject,
} from "aws-cdk-lib/aws-codebuild";
import { Artifact, Pipeline } from "aws-cdk-lib/aws-codepipeline";
import {
  CloudFormationCreateUpdateStackAction,
  CodeBuildAction,
  GitHubSourceAction,
} from "aws-cdk-lib/aws-codepipeline-actions";

export class PipelineStack extends Stack {
  constructor(scope: App, id: string, props: StackProps) {
    super(scope, id, props);

    const versions_pipeline = new Pipeline(this, "VersionsPipeline", {
      pipelineName: "VersionPipeline",
      crossAccountKeys: false,
    });

    const sourceOutput = new Artifact("VersionsSource");

    versions_pipeline.addStage({
      stageName: "Source",
      actions: [
        new GitHubSourceAction({
          owner: "my-git-username",
          repo: "my-git-repo",
          branch: "main",
          actionName: "PipelineSource",
          oauthToken: SecretValue.secretsManager("github-pipeline-secret"),
          output: sourceOutput,
        }),
      ],
    });

    const buildOutput = new Artifact("VersionBuild");
    versions_pipeline.addStage({
      stageName: "VersionBuild",
      actions: [
        new CodeBuildAction({
          actionName: "VersionBuild",
          input: sourceOutput,
          outputs: [buildOutput],
          project: new PipelineProject(this, "VersionBuildProject", {
            environment: {
              buildImage: LinuxBuildImage.STANDARD_5_0,
            },
            buildSpec: BuildSpec.fromSourceFilename("versions-build-spec.yml"),
          }),
        }),
      ],
    });

    versions_pipeline.addStage({
      stageName: "PipelineUpdate",
      actions: [
        new CloudFormationCreateUpdateStackAction({
          actionName: "PipelineUpdate",
          stackName: "PipelineStack",
          templatePath: buildOutput.atPath(
            "cdk-my-sst-app-versions-pipeline.template.json"
          ),
          adminPermissions: true,
        }),
      ],
    });
  }
}
f

Frank

04/28/2022, 12:20 AM
Hey @Neel, did you managed to get it to work?
The build output is at
.build/cdk.out
. Are you able to point it there?
n

Neel

06/17/2022, 10:56 AM
Hey @Frank, Apologies for being late. Yes, the build output is at
.build/cdk.out
But I wasn't able to point it there. For some reason, it wasn't automatically working for me. We moved to GitHub actions for now.
Thanks
2 Views