
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"kms:Decrypt",
"ssm:GetParametersByPath",
"ssm:GetParameters",
"ssm:GetParameter"
],
"Resource": [
"arn:aws:kms:*:*:key/*",
"arn:aws:ssm:*:*:parameter/sap*"
]
}
]
}
User which will be used in AWS CLI to access the Credentials
Now verify that the above user has no access to KMS and Parameter Store through AWS Console. The screen of verification is as follows:
No KMS Access Through AWS Console
No Parameter Store Access Through AWS Console
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"lambda:CreateFunction",
"lambda:UpdateFunctionEventInvokeConfig",
"lambda:UpdateEventSourceMapping",
"kms:Decrypt",
"lambda:UpdateFunctionCodeSigningConfig",
"lambda:InvokeFunction",
"lambda:ListVersionsByFunction",
"lambda:GetFunction",
"lambda:UpdateFunctionConfiguration",
"lambda:InvokeAsync",
"lambda:GetFunctionConfiguration",
"ssm:GetParameters",
"ssm:GetParameter",
"lambda:UpdateCodeSigningConfig",
"lambda:UpdateFunctionCode",
"ssm:GetParametersByPath"
],
"Resource": [
"arn:aws:lambda:*:802160044962:codesigningconfig:*",
"arn:aws:lambda:*:802160044962:event-source-mapping:*",
"arn:aws:lambda:*:802160044962:function:*",
"arn:aws:kms:*:*:key/*",
"arn:aws:ssm:*:*:parameter/*"
]
},
{
"Sid": "VisualEditor1",
"Effect": "Allow",
"Action": "lambda:CreateFunction",
"Resource": "arn:aws:lambda:*:802160044962:function:*"
},
{
"Sid": "VisualEditor2",
"Effect": "Allow",
"Action": [
"lambda:ListFunctions",
"lambda:GetAccountSettings"
],
"Resource": "*"
}
]
}
User with Lambda Function Execute Access
Verify that the above user has no additional access after login with AWS Console:
No KMS Access
No Parameter Store Access through AWS Console
Lambda Function Access through AWS Console
Go to KMS->Customer Managed Key->Create Key->Symmetric
KMS Customer Managed Key Creation Process
Go to Parameter Store and Create different credentials and URL whose detail is given in the following screen shot:
Parameter Store Detail Creation
Please make sure that you plan for proper Hierarchy planned before maintaining your credential in the Parameter store. This is essential because based on this hierarchy your access through Lambda Code will be defined. Also it will give a standard approach of maintaining your credentials or URL. Please have a look into the following screen shot which will give you one such example:
If you are using AWS EC2 server as Bastion host and trying to access the parameters store then there is no need for fresh installation of AWS CLI as EC2 is already coming with default AWS CLI installed.
If the SAP admin team is using it's own Laptop or Desktop then they need to install this tool separately. Please follow the following link to get this tool installed:
https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-windows.html
Once AWS CLI installed then use AWS Configure command to configure your Command line to communicate with your AWS account. Here you need to ask for "Access Key ID" and "Secret access Key" of the users which has been created above by your security team. The example of the credential file (.csv) is as follows:
AWS Configure command:
Now one can access the required details using the following commands:
aws ssm get-parameters --names <name of the parameter> --with-decryption --region <region_name>
EXAMPLE: aws ssm get-parameters --names /sap/abap/ecc/dev/ddic --with-decryption --region us-east-2
Command to get Encrypted Credential One at a time
One can use the following command to get the detail of all the Credentials/URL which are available in a particular path:
aws ssm get-parameters-by-path --path <path_detail> --recursive --with-decryption --region <region_name>
EXAMPLE: aws ssm get-parameters-by-path --path /sap/ --recursive --with-decryption --region us-east-2
Getting Credentials Based on Path
import json
import boto3
import os
ssm = boto3.client('ssm', region_name="us-east-2")
abap_or_java = os.environ['ABAP_OR_JAVA']
ecc_or_srm = os.environ['ECC_OR_SRM']
sap_env = os.environ['DEV_OR_UAT_OR_PRD']
sap_usr = os.environ['USER_NAME']
def lambda_handler(event, context):
user_password = ssm.get_parameters(Names=["/sap/" +abap_or_java+"/"+ecc_or_srm +"/"+sap_env +"/"+sap_usr], WithDecryption=True)
print(user_password)
return "done!"
Lambda Function
Lambda Function Creation
Variable detail
Lambda Function Automatically Generated Role
Lambda Role Modification for addition of Inline Policy
Time Out Setting
Lambda Function Execution and Result
Auditing and Monitoring
Parameter Store Pricing Tier
Lambda Function Execution Pricing Detail
KMS Pricing Detail
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
15 | |
5 | |
3 | |
3 | |
3 | |
2 | |
2 | |
2 | |
2 | |
2 |