aws / aws-toolkit-azure-devops

AWS Toolkit for Azure DevOps
Other
245 stars 104 forks source link

Use s3ObjectKey or randomize S3 object name when uploading Cloudformation template #524

Open fischaz opened 1 year ago

fischaz commented 1 year ago

Is your feature request related to a problem? Please describe.

I'm trying to use a "Common" Azure devops asset s3 bucket to store (temporarily) all CF template when I use the task CloudFormationCreateOrUpdateStack@1

to avoid creating too many buckets and all, I created a shared bucket in the CICD AWS account and shared it with my ORG, and then each account Azure Devops deployment role has read/write access to teh bucket to temporarily use it to store the CF template if required...

This makes my task look like this:

          - task: CloudFormationCreateOrUpdateStack@1
            name: DeployTransitGateway
            displayName: "Deploy Transit Gateway"
            inputs:
              awsCredentials: 'AzureDevopsSecurityDeploymentRole'
              regionName: 'ap-southeast-2'
              stackName: 'transit-gateway'
              templateSource: 'file'
              templateFile: 'templates/transit-gateway.yaml'
              templateParametersFile: 'configs/ap-southeast-2/transit-gateway.yaml'
              s3BucketName: 'azuredevops-assets-xxxxxxxxx-ap-southeast-2'
              s3ObjectKey: '437044670697/ap-southeast-2/transit-gateway.yaml'

Sadly, with this model, the upload of the CF template does work in the specified bucket, but uses the "basename" of the file to upload as the S3 object Key...

this poses a risk that someone / something, may use the same "template name" in a Different Azure Devops project / repository, and may break S3/CF deployment due to a race condition:

Describe the solution you'd like

I have 2 options in mind:

Describe alternatives you've considered

Yes - I know I could add a pre-task to do the S3 Upload to whatever path I need and then change the CloudFormationCreateOrUpdateStack@1 task to set templateSource: s3 and specify the key. But this is just too much work at this time for something that CloudFormationCreateOrUpdateStack@1 almost does.

Additional context