See S3_BUCKET below, which is first expanded from ImportValue, then used in BuildSpec.
AvUsageQuarantineBuildProject: Type: AWS::CodeBuild::Project Condition: Preprod Properties: Name: av-usage-quarantine-build ServiceRole: !GetAtt AvUsageQuarantineBuildProjectRole.Arn Artifacts: Type: CODEPIPELINE Name: av-usage-quarantine Environment: Type: LINUX_CONTAINER ComputeType: BUILD_GENERAL1_SMALL Image: aws/codebuild/java:openjdk-8 EnvironmentVariables: - Name: S3_BUCKET Value: !ImportValue delivery-AvDeliveryUtilsBucket Source: Type: CODEPIPELINE BuildSpec: !Sub | version: 0.2 phases: install: commands: - cd ~; wget https://raw.github.com/technomancy/leiningen/stable/bin/lein; chmod +x lein; mv lein /bin - LEIN_ROOT=true lein build: commands: - cd $CODEBUILD_SRC_DIR - LEIN_ROOT=true lein uberjar post_build: commands: - aws cloudformation package --template template.yaml --s3-bucket $S3_BUCKET --s3-prefix lambda --output-template av-usage-quarantine-output-template.yaml