This guide provides step-by-step instructions for deploying a security-hardened Amazon Q Business application designed for security incident response and playbook management. The solution creates an AI-powered search and chat interface that allows security teams to quickly find and interact with security playbooks using natural language queries.
This secure version includes the following security improvements over the standard implementation:
The solution deploys:
Download the secure template: Q-SecurityPlaybooks-Secure.yaml
aws sso-admin list-instances
aws cloudformation deploy \
--template-file Q-SecurityPlaybooks-Secure.yaml \
--stack-name q-security-playbooks-secure \
--parameter-overrides \
ApplicationName=security-playbooks \
AwsPlaybooksBucketName=aws-security-playbooks \
CxPlaybooksBucketName=custom-security-playbooks \
IdentityCenterInstanceArn=arn:aws:sso:::instance/ssoins-xxxxxxxxxx \
--capabilities CAPABILITY_IAM \
--region us-east-1
git clone https://github.com/aws-samples/aws-customer-playbook-framework.git
cd aws-customer-playbook-framework
aws s3 sync . s3://aws-security-playbooks-YOUR_ACCOUNT_ID/ --exclude ".git/*"
aws s3 ls s3://aws-security-playbooks-YOUR_ACCOUNT_ID/ --recursive
Prepare your custom playbooks in a local directory
aws s3 cp your-custom-playbooks/ s3://custom-security-playbooks-YOUR_ACCOUNT_ID/ --recursive
â ď¸ Important: This secure version removes IAM user groups. All user management must be done through Identity Center.
Create a Lambda function with enhanced security for automatic updates:
Select Python 3.11 (or latest available)
logger = logging.getLogger() logger.setLevel(logging.INFO)
def lambda_handler(event: Dict[str, Any], context: Any) -> Dict[str, Any]: âââ Secure AWS Lambda function to sync AWS Customer Playbook Framework to S3. Enhanced with better error handling and security logging. âââ try: # Clean up any existing files if os.path.exists(â/tmp/playbooksâ): subprocess.run([ârmâ, â-rfâ, â/tmp/playbooksâ], check=True)
# Clone latest from GitHub with security verification
logger.info("Cloning repository with security verification...")
result = subprocess.run(
['git', 'clone', '--depth', '1', '--single-branch',
'https://github.com/aws-samples/aws-customer-playbook-framework.git',
'/tmp/playbooks'],
capture_output=True,
text=True,
check=True,
timeout=300 # 5 minute timeout
)
# Initialize S3 client with enhanced security
s3 = boto3.client('s3')
bucket_name = os.environ['BUCKET_NAME']
# Verify bucket exists and we have access
try:
s3.head_bucket(Bucket=bucket_name)
except Exception as e:
raise Exception(f"Cannot access bucket {bucket_name}: {str(e)}")
# Upload files to S3 with metadata
logger.info(f"Uploading files to S3 bucket: {bucket_name}")
files_uploaded = 0
for root, _, files in os.walk('/tmp/playbooks'):
for file in files:
if not file.startswith('.git') and not file.startswith('.'):
local_path = os.path.join(root, file)
s3_key = os.path.relpath(local_path, '/tmp/playbooks')
# Add metadata for tracking
s3.upload_file(
Filename=local_path,
Bucket=bucket_name,
Key=s3_key,
ExtraArgs={
'Metadata': {
'source': 'automated-sync',
'sync-timestamp': str(context.aws_request_id)
},
'ServerSideEncryption': 'aws:kms'
}
)
files_uploaded += 1
# Log successful completion
logger.info(f"Successfully uploaded {files_uploaded} files to S3")
# Trigger Q Business data source sync
qbusiness = boto3.client('qbusiness')
app_id = os.environ.get('QBUSINESS_APP_ID')
data_source_id = os.environ.get('QBUSINESS_DATA_SOURCE_ID')
index_id = os.environ.get('QBUSINESS_INDEX_ID')
if all([app_id, data_source_id, index_id]):
try:
qbusiness.start_data_source_sync_job(
applicationId=app_id,
dataSourceId=data_source_id,
indexId=index_id
)
logger.info("Triggered Q Business data source sync")
except Exception as e:
logger.warning(f"Could not trigger Q Business sync: {str(e)}")
return {
'statusCode': 200,
'body': json.dumps({
'message': f'Successfully uploaded {files_uploaded} files to S3',
'bucket': bucket_name,
'files_uploaded': files_uploaded
})
}
except subprocess.CalledProcessError as e:
error_message = f"Git clone failed: {e.stderr}"
logger.error(error_message)
raise Exception(error_message)
except Exception as e:
error_message = f"Error occurred: {str(e)}"
logger.error(error_message)
raise Exception(error_message)
finally:
# Secure cleanup
if os.path.exists('/tmp/playbooks'):
subprocess.run(['rm', '-rf', '/tmp/playbooks'], check=True) ```
BUCKET_NAME: Your AWS playbooks S3 bucket nameQBUSINESS_APP_ID: Your Q Business application ID (from CloudFormation outputs)QBUSINESS_DATA_SOURCE_ID: Your data source IDQBUSINESS_INDEX_ID: Your index IDSecurePlaybookUpdateSecure automated playbook updatesScheduleThe secure version includes additional components that may affect costs:
| Component | Configuration | Monthly Cost (USD) |
|---|---|---|
| Amazon Q Business Lite | 4,500 users Ă $3/user | $13,500 |
| Amazon Q Business Pro | 500 users Ă $20/user | $10,000 |
| Enterprise Index | 50 index units Ă $0.264/hour | $9,504 |
| AWS Lambda | 1M requests/month | $46.91 |
| Amazon API Gateway | 1M requests/month | $5 |
| S3 Access Logging | Additional storage costs | ~$50-100 |
| KMS Encryption | Additional key usage | ~$10-20 |
| Enhanced Monitoring | CloudWatch logs/metrics | ~$25-50 |
| Total Estimated Cost | Â | $33,140-$33,225 |
To avoid ongoing charges and ensure complete cleanup:
aws cloudformation delete-stack --stack-name q-security-playbooks-secure
This secure implementation guide provides enhanced security controls for AWS Q Business deployment. Customers are responsible for:
AWS products and services are provided âas isâ without warranties. This guidance represents current best practices and is subject to change. Always consult the latest AWS documentation and security best practices for your specific use case.