aws-deployment-framework icon indicating copy to clipboard operation
aws-deployment-framework copied to clipboard

param_overrides does not support more than 1 parameter (per input)

Open Nr18 opened this issue 2 years ago • 1 comments

When you make use of the param_overrides functionality and need to pass more than 1 parameter per input the pipeline will fail to deploy. For example:

pipelines:
  - name: my-pipeline
    default_providers:
      source:
        provider: codecommit
        properties:
          account_id: XXXXXXXXXXXX
      build:
        provider: codebuild
        properties:
          image: STANDARD_4_0
          environment_variables:
            CONTAINS_TRANSFORM: True
      deploy:
        provider: cloudformation
    targets:
      - name: FirstStack
        regions: eu-west-1
        target: XXXXXXXXXXXX
        properties:
          outputs: outputs
      - name: SecondStack
        regions: eu-west-1
        target: XXXXXXXXXXXX
        properties:
          root_dir: ./second-stack
          param_overrides:
            - inputs: outputs
              param: FirstParam
              key_name: FirstParam
            - inputs: outputs
              param: SecondParam
              key_name: SecondParam

This will lead into the following CloudFormation snippet:

{
  "Actions": [
    {
      "ActionTypeId": {
        "Category": "Deploy",
        "Owner": "AWS",
        "Provider": "CloudFormation",
        "Version": "1"
      },
      "Configuration": {
        "ActionMode": "CHANGE_SET_REPLACE",
        "StackName": "my-stack",
        "ChangeSetName": "my-stack",
        "TemplateConfiguration": "my-stack-build::./second-stack/params/account_name_eu-west-1.json",
        "Capabilities": "CAPABILITY_NAMED_IAM,CAPABILITY_AUTO_EXPAND",
        "RoleArn": "arn:aws:iam::XXXXXXXXXXXX:role/adf-cloudformation-deployment-role",
        "TemplatePath": "my-stack-build::./second-stack/template_eu-west-1.yml",
        "ParameterOverrides": "{\"FirstParam\": {\"Fn::GetParam\": [\"outputs\", \"outputs.json\", \"FirstParam\"]}, \"KeyArn\": {\"Fn::GetParam\": [\"outputs\", \"outputs.json\", \"SecondParam\"]}}"
      },
      "InputArtifacts": [
        {
          "Name": "my-stack-build"
        },
        {
          "Name": "outputs"
        },
        {
          "Name": "outputs"
        }
      ],
      "Name": "account_name-eu-west-1-create",
      "Region": "eu-west-1",
      "RoleArn": "arn:aws:iam:: XXXXXXXXXXXX:role/adf-cloudformation-role",
      "RunOrder": 1
    }
  ]
}

As you can see the outputs artifact InputArtifacts is duplicated. This is triggered by https://github.com/awslabs/aws-deployment-framework/blob/0723ddf4eaf55888ae780dc48873f0ec4766cfbd/src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/cdk/cdk_constructs/adf_codepipeline.py#L374:

            for override in self.target.get('properties', {}).get('param_overrides', []):
                    if self.provider == "CloudFormation" and override.get('inputs') and self.action_mode != "CHANGE_SET_EXECUTE":
                    input_artifacts.append(
                        _codepipeline.CfnPipeline.InputArtifactProperty(
                            name=override.get('inputs')
                        )
                    )

It will always add the input regardless if it's already there.

Nr18 avatar Mar 08 '22 10:03 Nr18

Good catch, thanks for reporting

sbkok avatar Mar 11 '22 09:03 sbkok

Thank you for your patience. I am happy to inform you that this issue has been resolved in our latest release v3.2.0 just now. I'm hereby closing this issue. Please open a new issue if you are experiencing any issues with the latest release.

sbkok avatar Jan 24 '23 10:01 sbkok