Bug: Config file permissions_provider parameter conflict when using bootstrapping with OIDC
- Dominant language
- Python
- Stars
- 6.7k
- Forks
- 1.2k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 52
Description
### Description:
When using a config file to bootstrap OIDC there is a conflict with the `permissions_provider` parameter.
In [`bootstrap cli`](https://github.com/aws/aws-sam-cli/blob/5e90c508d50fc57b786d1076bab351c3144ddd77/samcli/commands/pipeline/bootstrap/cli.py#L36) the available permission providers are:
`PERMISSIONS_PROVIDERS = [OPEN_ID_CONNECT, IAM]`
However, when boot strapping, the `permissions_provider` is checked against [OPENID_CONNECT](https://github.com/aws/aws-sam-cli/blob/5e90c508d50fc57b786d1076bab351c3144ddd77/samcli/commands/pipeline/bootstrap/cli.py#L307) which is defined as `"OpenID Connect (OIDC)"` and is not one of `PERMISSIONS_PROVIDERS`. This results in the `oidc_config` update being unreachable and the `Missing required parameter '--oidc-provider'` exception being raised even though it is present in the config file.
This issue is confirmed by the config file produced by the interactive bootstrapping, `.aws-sam/pipeline/pipelinconfig.toml`, as it contains the parameter `permissions_provider = "OpenID Connect (OIDC)"` which is not a valid option for the CLI.
### Steps to reproduce:
Attempt to bootstrap with the following config `sam pipeline bootstrap --config-file stages/dev.toml`:
```
version=0.1
[default.global.parameters]
stage = "dev"
region = "eu-west-2"
[default.pipeline_bootstrap]
[default.pipeline_bootstrap.parameters]
interactive = false
confirm_changeset = false
use_oidc_provider = true
permissions_provider = "oidc"
oidc_provider = "gitlab"
oidc_provider_url = "https://gitlab.com"
oidc_client_id = "https://gitlab.com"
gitlab_group = "group"
gitlab_project = "project"
deployment_branch = "*"
```
### Observed result:
```
2023-04-05 12:37:40,382 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2023-04-05 12:37:40,382 | Using config file: stages/dev.toml, config environment: default
2023-04-05 12:37:40,382 | Expand command line arguments to:
2023-04-05 12:37:40,382 | --stage=dev-robot-data-backend --permissions_provider=oidc --oidc_provider_url=https://gitlab.com --oidc_client_id=https://gitlab.com --deployment_branch=* --oidc_provider=gitlab --gitlab_group=q-bot --gitlab_project=project
2023-04-05 12:37:40,387 | Template is not provided in context, skip adding project type metric
2023-04-05 12:37:40,468 | Sending Telemetry: {'metrics': [{'commandRun': {'requestId': 'e7d45a80-7aa6-490e-bbf3-e3b724acfc62', 'installationId': '8712d42f-245e-4941-9703-a0354abe4160', 'sessionId': '68970716-b7ac-40a9-84fb-f26753ee1eca', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.8.8', 'samcliVersion': '1.61.0', 'awsProfileProvided': False, 'debugFlagProvided': True, 'region': 'eu-west-2', 'commandName': 'sam pipeline bootstrap', 'metricSpecificAttributes': {'gitOrigin': 'dbe3a6eb8f695b64845e2c66499d57288ece0f7249fb9c8726618ecff0c41340', 'projectName': '6b42b7f77a8b524942081b9063835192d7d62ef3974c119903e36940dc049bd9', 'initialCommit': '1113dd0896a741fd393a80f68ecba784883b46fe8ab8bef2f4e26639ac6a0dd9'}, 'duration': 86, 'exitReason': 'UsageError', 'exitCode': 255}}]}
2023-04-05 12:37:41,068 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)
Usage: sam pipeline bootstrap [OPTIONS]
Try 'sam pipeline bootstrap -h' for help.
Error: Missing required parameter '--oidc-provider'
Traceback (most recent call last):
File "C:\Users\Ashley Napier\PycharmProjects\pythonProject\robot-cicd-deployment-iam-configuration\scripts\deploy.py", line 45, in
sam_bootstrap(sam_config)
File "C:\Users\Ashley Napier\PycharmProjects\pythonProject\robot-cicd-deployment-iam-configuration\scripts\deploy.py", line 37, in sam_bootstrap
run_command(command_bootstrap)
File "C:\Users\Ashley Napier\PycharmProjects\pythonProject\robot-cicd-deployment-iam-configuration\scripts\deploy.py", line 10, in run_command
raise OSError(f"Command failed: {' '.join(command)}\n{result.stderr}")
```
### Expected result:
Bootstrapping completes as expected
### Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
{
"version": "1.78.0",
"system": {
"python": "3.8.8",
"os": "Windows-10-10.0.19041-SP0"
},
"additional_dependencies": {
"docker_engine": "20.10.17",
"aws_cdk": "Not available",
"terraform": "Not available"
}
}
Contributor guide
Assessment
This issue has not been assessed yet.