title: Invalidate Cloudfront cache with AWS CDK Pipelines
body: <p>As part of my CodePipeline in CDK I would like, as the last step, to invalidate the Cloudfront cache.</p>
  <p>This is my current Deploy action step:</p>
  <pre><code>{
    stageName: 'Deploy',
    actions: [
      new codepipelineActions.S3DeployAction({
        actionName: 'S3Deploy',
        bucket: frontendCodeBucket, // See bucket config below
        input: buildOutput, // Output from Build step
      }),
    ]
  }
  </code></pre>
  <p>And here is my code bucket and CF distribution:</p>
  <pre><code>const frontendCodeBucket = new s3.Bucket(this, 'FrontendBucketStaging', {
    websiteIndexDocument: 'index.html',
    encryption: s3.BucketEncryption.S3_MANAGED,
    blockPublicAccess: s3.BlockPublicAccess.BLOCK_ALL,
    bucketName: 'something',
    removalPolicy: RemovalPolicy.DESTROY,
  });
  
  
  const distribution = new cloudfront.CloudFrontWebDistribution(this, 'FrontendCloudfrontStaging', {
    originConfigs: [
      {
        s3OriginSource: {
          s3BucketSource: frontendCodeBucket,
          originAccessIdentity: oai,
        },
        behaviors : [ {isDefaultBehavior: true}]
      }
    ],
  </code></pre>
  <p>I can't find any way to invalidate the cache through S3DeployAction.
  It seems like one of the most common thing one would want to do when working with a static website and Cloudfront. Is it simply just not possible?</p>
  <p>If it's not. Is there a workaround?
  For example, in a non pipeline-process, something like this should work (what I've read):</p>
  <pre><code>new s3deploy.BucketDeployment(this, 'DeployWithInvalidation', {
    sources: [&lt;some assets&gt;],
    destinationBucket: bucket,
    distribution,
    distributionPaths: ['/*'],
  });
  </code></pre>
  <p>Is there then a way to add such a step in the pipeline, that is not an &quot;Action&quot;?</p>
  <p>Very happy for any help or pointers. I'm quite new to CDK, but this just felt like such a common thing that someone would want to do, so I hope I'm just missing something here. Apart from this last step, the pipeline works great.</p>