diff --git a/src/generic_lambda_credentials_rotator/README.md b/src/generic_lambda_credentials_rotator/README.md new file mode 100644 index 0000000..409603a --- /dev/null +++ b/src/generic_lambda_credentials_rotator/README.md @@ -0,0 +1,105 @@ +# Generic Lambda Credentials Rotator + +Generic Lambda Credentials Rotator is a AWS Lambda function that can be used to move credentials and other artifacts from one source to another destination. This package can be included into any cdk package to enable credential rotation. Few use cases: + +1. Create temprorary AWS credentials and push the credentials to CircleCI environment variable. +2. Move values in lambda environment variable to CircleCI environment variable. +3. Move values in AWS Secrets Manager to CircleCI environment variable. + +## Destination supported: + +- CircleCI environment variable + - Input structure: + ``` + "": { + "type": "cci_env_variable", + "description": "", + "github_path": "/", + "circleci_api_token_secret_id_lambda_env_var_key": "" + } + ``` + - AWS Lambda requires api token from CircleCI to push values to CircleCI environment variable. This api key should be stored in AWS Secrets Manager, and the key for the secret should be stored as environment variable in lambda function. `circleci_api_token_secret_id_lambda_env_var_key` above stores the key info for this lambda environment variable. + +## Sources supported: + +- AWS Session Credentials +- Lambda environment Variables +- Secrets in AWS Secrets Manager + +## Complete Input format: + +```cli +{ + "sources": [ + { + "type": "aws_session_cred", + "description": "Temporary AWS Credentials to upload the release artifacts to S3 and invalidate Cloudfront", + "configuration": { + "user_env_variable": "IAM_USERNAME", + "iam_role_env_variable": "IAM_ROLE" + }, + "destination": { + "specifier": "aws-sdk-ios-cci", + "mapping_to_destination": [ + { + "destination_key_name": "XCF_ACCESS_KEY_ID", + "result_value_key": "access_key_id" + }, + { + "destination_key_name": "XCF_SECRET_ACCESS_KEY", + "result_value_key": "secret_access_key" + }, + { + "destination_key_name": "XCF_SESSION_TOKEN", + "result_value_key": "session_token" + } + ] + } + }, + { + "type": "secrets_manager", + "description": "", + "configuration": { + "secret_key_env_variable": "GITHUB_CREDENTIALS_SECRET" + }, + "destination": { + "specifier": "aws-sdk-ios-cci", + "mapping_to_destination": [ + { + "destination_key_name": "GITHUB_SPM_TOKEN", + "result_value_key": "GITHUB_SPM_TOKEN" + }, + { + "destination_key_name": "GITHUB_SPM_USER", + "result_value_key": "GITHUB_SPM_USER" + } + ] + } + }, + { + "type": "lambda_env_variables", + "description": "", + "configuration": { + "lambda_env_var_key": "SPM_S3_BUCKET_NAME" + }, + "destination": { + "specifier": "aws-sdk-ios-cci", + "mapping_to_destination": [ + { + "destination_key_name": "XCF_S3_BUCKET_NAME" + } + ] + } + } + ], + "destinations": { + "aws-sdk-ios-cci": { + "type": "cci_env_variable", + "description": "Circle CI environment variable for AWS SDK iOS repo", + "github_path": "aws-amplify/aws-sdk-ios", + "circleci_api_token_secret_id_lambda_env_var_key": "CIRCLE_CI_IOS_SDK_API_TOKEN" + } + } + } + +``` \ No newline at end of file diff --git a/src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/__init__.py b/src/generic_lambda_credentials_rotator/lambda_functions/__init__.py similarity index 100% rename from src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/__init__.py rename to src/generic_lambda_credentials_rotator/lambda_functions/__init__.py diff --git a/src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/src/__init__.py b/src/generic_lambda_credentials_rotator/lambda_functions/src/__init__.py similarity index 100% rename from src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/src/__init__.py rename to src/generic_lambda_credentials_rotator/lambda_functions/src/__init__.py diff --git a/src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/src/destination/__init__.py b/src/generic_lambda_credentials_rotator/lambda_functions/src/destination/__init__.py similarity index 100% rename from src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/src/destination/__init__.py rename to src/generic_lambda_credentials_rotator/lambda_functions/src/destination/__init__.py diff --git a/src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/src/destination/circleci.py b/src/generic_lambda_credentials_rotator/lambda_functions/src/destination/circleci.py similarity index 100% rename from src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/src/destination/circleci.py rename to src/generic_lambda_credentials_rotator/lambda_functions/src/destination/circleci.py diff --git a/src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/src/handler.py b/src/generic_lambda_credentials_rotator/lambda_functions/src/handler.py similarity index 100% rename from src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/src/handler.py rename to src/generic_lambda_credentials_rotator/lambda_functions/src/handler.py diff --git a/src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/src/models/__init__.py b/src/generic_lambda_credentials_rotator/lambda_functions/src/models/__init__.py similarity index 100% rename from src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/src/models/__init__.py rename to src/generic_lambda_credentials_rotator/lambda_functions/src/models/__init__.py diff --git a/src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/src/models/destination_type.py b/src/generic_lambda_credentials_rotator/lambda_functions/src/models/destination_type.py similarity index 100% rename from src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/src/models/destination_type.py rename to src/generic_lambda_credentials_rotator/lambda_functions/src/models/destination_type.py diff --git a/src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/src/models/source_type.py b/src/generic_lambda_credentials_rotator/lambda_functions/src/models/source_type.py similarity index 100% rename from src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/src/models/source_type.py rename to src/generic_lambda_credentials_rotator/lambda_functions/src/models/source_type.py diff --git a/src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/src/requirements.txt b/src/generic_lambda_credentials_rotator/lambda_functions/src/requirements.txt similarity index 100% rename from src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/src/requirements.txt rename to src/generic_lambda_credentials_rotator/lambda_functions/src/requirements.txt diff --git a/src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/src/source_data_generator/__init__.py b/src/generic_lambda_credentials_rotator/lambda_functions/src/source_data_generator/__init__.py similarity index 100% rename from src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/src/source_data_generator/__init__.py rename to src/generic_lambda_credentials_rotator/lambda_functions/src/source_data_generator/__init__.py diff --git a/src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/src/source_data_generator/aws_session_credential_source.py b/src/generic_lambda_credentials_rotator/lambda_functions/src/source_data_generator/aws_session_credential_source.py similarity index 100% rename from src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/src/source_data_generator/aws_session_credential_source.py rename to src/generic_lambda_credentials_rotator/lambda_functions/src/source_data_generator/aws_session_credential_source.py diff --git a/src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/src/source_data_generator/lambda_env_var_data_source.py b/src/generic_lambda_credentials_rotator/lambda_functions/src/source_data_generator/lambda_env_var_data_source.py similarity index 100% rename from src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/src/source_data_generator/lambda_env_var_data_source.py rename to src/generic_lambda_credentials_rotator/lambda_functions/src/source_data_generator/lambda_env_var_data_source.py diff --git a/src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/src/source_data_generator/secrets_data_source.py b/src/generic_lambda_credentials_rotator/lambda_functions/src/source_data_generator/secrets_data_source.py similarity index 100% rename from src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/src/source_data_generator/secrets_data_source.py rename to src/generic_lambda_credentials_rotator/lambda_functions/src/source_data_generator/secrets_data_source.py diff --git a/src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/src/utils/__init__.py b/src/generic_lambda_credentials_rotator/lambda_functions/src/utils/__init__.py similarity index 100% rename from src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/src/utils/__init__.py rename to src/generic_lambda_credentials_rotator/lambda_functions/src/utils/__init__.py diff --git a/src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/src/utils/retry.py b/src/generic_lambda_credentials_rotator/lambda_functions/src/utils/retry.py similarity index 100% rename from src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/src/utils/retry.py rename to src/generic_lambda_credentials_rotator/lambda_functions/src/utils/retry.py diff --git a/src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/src/utils/secrets_manager_helper.py b/src/generic_lambda_credentials_rotator/lambda_functions/src/utils/secrets_manager_helper.py similarity index 100% rename from src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/src/utils/secrets_manager_helper.py rename to src/generic_lambda_credentials_rotator/lambda_functions/src/utils/secrets_manager_helper.py diff --git a/src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/test/__init__.py b/src/generic_lambda_credentials_rotator/lambda_functions/test/__init__.py similarity index 100% rename from src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/test/__init__.py rename to src/generic_lambda_credentials_rotator/lambda_functions/test/__init__.py diff --git a/src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/test/test_aws_credential_rotator.py b/src/generic_lambda_credentials_rotator/lambda_functions/test/test_aws_credential_rotator.py similarity index 100% rename from src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/test/test_aws_credential_rotator.py rename to src/generic_lambda_credentials_rotator/lambda_functions/test/test_aws_credential_rotator.py diff --git a/src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/test/test_circleci.py b/src/generic_lambda_credentials_rotator/lambda_functions/test/test_circleci.py similarity index 100% rename from src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/test/test_circleci.py rename to src/generic_lambda_credentials_rotator/lambda_functions/test/test_circleci.py diff --git a/src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/test/test_retry.py b/src/generic_lambda_credentials_rotator/lambda_functions/test/test_retry.py similarity index 100% rename from src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/test/test_retry.py rename to src/generic_lambda_credentials_rotator/lambda_functions/test/test_retry.py diff --git a/src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/test/test_secrets_data_source.py b/src/generic_lambda_credentials_rotator/lambda_functions/test/test_secrets_data_source.py similarity index 100% rename from src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/test/test_secrets_data_source.py rename to src/generic_lambda_credentials_rotator/lambda_functions/test/test_secrets_data_source.py diff --git a/src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/test/test_secrets_manager_helper.py b/src/generic_lambda_credentials_rotator/lambda_functions/test/test_secrets_manager_helper.py similarity index 100% rename from src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/test/test_secrets_manager_helper.py rename to src/generic_lambda_credentials_rotator/lambda_functions/test/test_secrets_manager_helper.py diff --git a/src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/test/test_static_data_source.py b/src/generic_lambda_credentials_rotator/lambda_functions/test/test_static_data_source.py similarity index 100% rename from src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/test/test_static_data_source.py rename to src/generic_lambda_credentials_rotator/lambda_functions/test/test_static_data_source.py diff --git a/src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/tests.py b/src/generic_lambda_credentials_rotator/lambda_functions/tests.py similarity index 100% rename from src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_functions/tests.py rename to src/generic_lambda_credentials_rotator/lambda_functions/tests.py diff --git a/src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_construct.py b/src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_construct.py index af7cafa..42ea0fb 100644 --- a/src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_construct.py +++ b/src/release_artifacts_resources/ios/cdk/cdk/credential_rotation/lambda_construct.py @@ -20,7 +20,7 @@ def __init__( self.credential_rotator = aws_lambda_python.PythonFunction( self, "credential_rotation_lambda", - entry="cdk/credential_rotation/lambda_functions/src", + entry="../../../generic_lambda_credentials_rotator/lambda_functions/src", index="handler.py", runtime=aws_lambda.Runtime.PYTHON_3_7, role=iam_construct.lambda_role,