I have modified a working configuration where the source is pulled from github, and then built on a windows build machine. I also need an S3 resource to be copied from a bucket. I have gone round and round with trying different things. The following configuration seems to be right according to all of the documentation I have read, but I still don't have access to the secondary source.
Here is my Cloudwatch Formation template file:
AWSTemplateFormatVersion: '2010-09-09'
Resources:
CareGaugeOneClientBuild:
Type: AWS::CodeBuild::Project
Properties:
Source:
Type: CODEPIPELINE
BuildSpec: devops/buildspec.yml
Visibility: PRIVATE
Name: caregaugeoneclient-build
Environment:
Type: WINDOWS_SERVER_2019_CONTAINER
PrivilegedMode: false
ImagePullCredentialsType: CODEBUILD
Image: {Not shown for example}
ComputeType: BUILD_GENERAL1_MEDIUM
ServiceRole: {Not shown for example}
Artifacts:
Type: CODEPIPELINE
LogsConfig:
CloudWatchLogs:
GroupName: {Not shown for example}
StreamName: build
Status: ENAB LED
GreyhavensPipelineDevCareGaugeOneClient:
Type: AWS::CodePipeline::Pipeline
Properties:
Name: dev-client-example
ArtifactStore:
Type: S3
Location: {Not shown for example}
RoleArn: {Not shown for example}
Stages:
- Actions:
- ActionTypeId:
Category: Source
Owner: AWS
Provider: CodeStarSourceConnection
Version: 1
Configuration:
BranchName: master
ConnectionArn: {Not shown for example}
FullRepositoryId: {Not shown for example}
OutputArtifactFormat: CODE_ZIP
InputArtifacts: []
Name: Source
Namespace: SourceVariables
OutputArtifacts:
- Name: SourceArtifact
Region: us-east-2
RunOrder: 1
- ActionTypeId:
Category: Source
Owner: AWS
Provider: S3
Version: 1
Configuration:
PollForSourceChanges: 'true'
S3Bucket: example-secrets
S3ObjectKey: CodeSign.pfx
InputArtifacts: []
Name: FetchExampleBuildCert
OutputArtifacts:
- Name: ExampleBuildCert
Region: us-east-2
RunOrder: 2
Name: Source
- Actions:
- ActionTypeId:
Category: Build
Owner: AWS
Provider: CodeBuild
Version: 1
Configuration:
EnvironmentVariables:
'[{"name":"COMMIT_ID","value":"#{SourceVariables.CommitId}","type":"PLAINTEXT"}]'
ProjectName: example-build
PrimarySource: SourceArtifact
InputArtifacts:
- Name: SourceArtifact
- Name: ExampleBuildCert
Name: Build
Namespace: BuildVariables
OutputArtifacts:
- Name: BuildArtifact
Region: us-east-2
RunOrder: 1
Name: Build
- Actions:
- ActionTypeId:
Category: Build
Owner: AWS
Provider: CodeBuild
Version: 1
Configuration:
ProjectName: example-cd
InputArtifacts:
- Name: BuildArtifact
Name: Deploy
OutputArtifacts: []
Region: us-east-2
RunOrder: 1
Name: Deploy
I have renamed many of the objects in the yml file, but again this is a working configuration other than the S3 secondary artifact.
Here is my buildspec.yml file:
version: 0.2
env:
variables:
SOLUTION: .\example.sln
PACKAGE_DIRECTORY: .\packages
DOTNET_FRAMEWORK: 4.8
phases:
pre_build:
commands:
- 'mkdir C:\BuildArtifacts' # Create a directory to store the copied file
- 'echo $env:CODEBUILD_SRC_DIR_ExampleBuildCert'
- 'dir -s $env:CODEBUILD_SRC_DIR_ExampleBuildCert/*.pfx'
Note that while I see all of the code in both $env:CODEBUILD_SRC_DIR and $env:CODEBUILD_SRC_DIR_ECBuildCert, I don't find the secondary artifact.
Ideas?