aw:cloudformation_policy
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| aw:cloudformation_policy [30/12/2024 22:36] – created andrew | aw:cloudformation_policy [02/01/2025 15:51] (current) – andrew | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== IAM Policy ====== | ====== IAM Policy ====== | ||
| + | Developer Policy to allow devs to inspect prod logs but not change deployed code. | ||
| + | |||
| + | |||
| + | ===== Policy ===== | ||
| + | |||
| + | dev_gr.yaml | ||
| + | <code yaml> | ||
| + | --- | ||
| + | AWSTemplateFormatVersion: | ||
| + | |||
| + | Description: | ||
| + | Stack to add policy and group to allow developers limited access to environments for debugging. | ||
| + | |||
| + | Parameters: | ||
| + | Environment: | ||
| + | Description: | ||
| + | Type: String | ||
| + | Default: sandbox | ||
| + | AllowedValues: | ||
| + | - production | ||
| + | - dev | ||
| + | - staging | ||
| + | ConstraintDescription: | ||
| + | |||
| + | Mappings: | ||
| + | NameToEnv: | ||
| + | production: | ||
| + | Account: " | ||
| + | dev: | ||
| + | Account: " | ||
| + | staging: | ||
| + | Account: " | ||
| + | |||
| + | Resources: | ||
| + | Developers: | ||
| + | Type: AWS:: | ||
| + | Properties: | ||
| + | GroupName: Devs | ||
| + | Path: / | ||
| + | |||
| + | |||
| + | DevsPolicy: | ||
| + | Type: " | ||
| + | DependsOn: Developers | ||
| + | Properties: | ||
| + | Description: | ||
| + | ManagedPolicyName: | ||
| + | Path: / | ||
| + | Groups: | ||
| + | - Devs | ||
| + | PolicyDocument: | ||
| + | Version: " | ||
| + | Statement: | ||
| + | - Action: | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | Effect: Allow | ||
| + | Resource: | ||
| + | - ' | ||
| + | |||
| + | |||
| + | |||
| + | - Action: | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | Effect: Allow | ||
| + | Resource: | ||
| + | - ' | ||
| + | |||
| + | - Action: | ||
| + | - " | ||
| + | Effect: Allow | ||
| + | Resource: | ||
| + | - " | ||
| + | |||
| + | - Action: | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | Effect: Allow | ||
| + | Resource: | ||
| + | - ' | ||
| + | |||
| + | |||
| + | - Action: | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | Effect: Allow | ||
| + | Resource: | ||
| + | - ' | ||
| + | |||
| + | - Action: | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | Effect: Allow | ||
| + | Resource: | ||
| + | - " | ||
| + | |||
| + | - Action: | ||
| + | - " | ||
| + | - " | ||
| + | Effect: Allow | ||
| + | Resource: | ||
| + | - " | ||
| + | |||
| + | - Action: | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | Effect: Allow | ||
| + | Resource: | ||
| + | - " | ||
| + | |||
| + | - Action: | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | Effect: Allow | ||
| + | Resource: | ||
| + | - " | ||
| + | |||
| + | - Action: | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | Effect: Allow | ||
| + | Resource: | ||
| + | - " | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | ===== Deploy Script ===== | ||
| + | |||
| + | Shel script to deploy policy | ||
| + | |||
| + | deploy_stack.sh | ||
| + | <code bash> | ||
| + | #!/bin/bash | ||
| + | #Written Andrew Stringer | ||
| + | #Purpose to deploy a cloudformation stack from the cli. | ||
| + | |||
| + | STACK_NAME=' | ||
| + | TEMPLATE_BODY=' | ||
| + | REGION=' | ||
| + | PROFILE=$1 | ||
| + | |||
| + | TAGS=" | ||
| + | |||
| + | echo "Using ${PROFILE}." | ||
| + | |||
| + | #Test $1 exists | ||
| + | if [ -z " | ||
| + | echo "Your AWS Profile is not set, using default" | ||
| + | PROFILE=default | ||
| + | fi | ||
| + | |||
| + | # who am i? | ||
| + | aws sts get-caller-identity --profile ${PROFILE} | ||
| + | |||
| + | aws cloudformation update-stack \ | ||
| + | --stack-name ${STACK_NAME} \ | ||
| + | --template-body ${TEMPLATE_BODY} \ | ||
| + | --region ${REGION} \ | ||
| + | --profile ${PROFILE} \ | ||
| + | --capabilities CAPABILITY_NAMED_IAM \ | ||
| + | --tags ${TAGS} | ||
| + | exit | ||
| + | </ | ||
aw/cloudformation_policy.1735598167.txt.gz · Last modified: by andrew
