Skip to content
This repository was archived by the owner on Sep 17, 2024. It is now read-only.

Commit 447aee0

Browse files
author
Ray Janoka
committed
Only requiring the build dependencies when building and clarifying the README
1 parent e339a0e commit 447aee0

File tree

2 files changed

+29
-25
lines changed

2 files changed

+29
-25
lines changed

README.md

+20-20
Original file line numberDiff line numberDiff line change
@@ -29,48 +29,48 @@ The infrastructure consists of:
2929
* CloudWatch Events Rule
3030
* SNS Topic
3131

32+
## Custom Tags
33+
34+
Add pre-defined static tagging or custom tagging from the CloudTrail event. Using a JSON document, define one or more tags with either a hard-coded value or a value extracted from the CloudTrail event using variable substitution. Hard-coded tags will be applied to all [supported AWS resources](#supported-resource-types). When using variable substitution more than one variable can be provided in a single tag value, and if all of the substitutions in the field fail to be resolved the tag will not be written. That will allow for custom tags to be created using certain CloudTrail event fields that may not exist in all CloudTrail event types. Check out the [CloudTrail Log Event Reference](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-event-reference.html) for the most common fields. Also, each AWS resource will have unique fields in the `requestParameters` and `responseElements` fields that can be used. Examples of specific AWS resource CloudTrail events can be found at [CloudTrail Log File Examples](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-log-file-examples.html) or by searching in the CloudTrail event history.
35+
36+
Example:
37+
38+
```json
39+
{
40+
"AutoTag_ManagedBy": "Site Reliability Engineering",
41+
"AutoTag_UserIdentityType": "$event.userIdentity.type",
42+
"AutoTag_UserName": "$event.userIdentity.userName",
43+
"AutoTag_ClientInfo": "SourceIP: $event.sourceIPAddress, UserAgent: $event.userAgent",
44+
"AutoTag_Ec2_ImageId": "$event.responseElements.instancesSet.items.0.imageId"
45+
}
46+
```
47+
3248
## Prerequisites
3349

3450
You will need at least 1 AWS Account, and CloudTrail should be enabled.
3551

3652
## Deployment Methods
3753

38-
We have documented two different ways to deploy the infrastructure to an AWS account. Since there are CloudFormation stacks that need to be deployed in multiple regions we've provided a script that uses the AWS CLI to deploy everything for you. The other deployment method has more steps and uses CloudFormation StackSets to deploy across multiple regions.
54+
We have documented two different ways to deploy the infrastructure to an AWS account. Since there are CloudFormation stacks that need to be deployed in multiple regions we've provided a script that uses the AWS CLI to deploy everything for you. The other deployment method uses CloudFormation StackSets to deploy across multiple regions.
3955

4056
### Script Deployment Method: Deploy through our script
4157

4258
This deploy script `deploy_autotag.sh` will create, delete, or update all of the AutoTag infrastructure for a single AWS account.
4359

4460
The script will attempt to auto-install its own dependencies: `aws-cli`, `jq`, `npm`, `git`, `zip`
4561

46-
The `create` command will start by creating a dedicated AutoTag S3 Bucket for storing code deployment packages in your AWS account. Then it will download or build the code package, and create both the main CloudFormation stack and the collector CloudFormation stacks. When executing the `delete` command all resources will be removed except the S3 bucket.
62+
The `create` command will start by creating a dedicated AutoTag S3 Bucket for storing code deployment packages in your AWS account. Then it will download or build the code package, and create both the main CloudFormation stack and the collector CloudFormation stacks. When executing the `delete` command all resources will be removed except the S3 bucket. Use the `update-release` command to update existing CloudFormation stacks to a specific release, `update-master` to update to the master branch (build required), or `update-local` to update to the local cloned git repo (build required).
4763

4864
#### Credentials
4965

50-
The deploy script can use all of the credential providers that the AWS CLI allows, see [Configure AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html) and take a look at the examples below. A separate set of CLI credentials can be provided by the argument `--s3-profile` for utilizing a single S3 bucket when deploying infrastructure across multiple AWS accounts. The script will also secure the S3 bucket by blocking all public access configuration, and add the required S3 bucket-policy statement to allow the cross-account `GetObject` access if necessary.
66+
The deploy script can use all of the credential providers that the AWS CLI allows, see [Configure AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html) and take a look at the [deployment examples](#deployment-examples). A separate set of CLI credentials can be provided by the argument `--s3-profile` for utilizing a single S3 bucket when deploying infrastructure across multiple AWS accounts. The script will also secure the S3 bucket by blocking all public access configuration, and add the required S3 bucket-policy statement to allow the cross-account `GetObject` access if necessary.
5167

5268
#### IAM Policy Permissions
5369

5470
The script needs at minimum the IAM permissions described in this policy: [deploy\_iam\_policy.json](deploy_iam_policy.json)
5571

5672
Before using this IAM policy replace the 2 occurrences of `my-autotag-bucket` with the name of your actual AutoTag S3 bucket.
5773

58-
#### Custom Tags
59-
60-
Add pre-defined static tagging or custom tagging from the CloudTrail event. Using a JSON document, define one or more tags with either a hard-coded value or a value extracted from the CloudTrail event using variable substitution. Hard-coded tags will be applied to all [supported AWS resources](#supported-resource-types). When using variable substitution more than one variable can be provided in a single tag value, and if all of the substitutions in the field fail to be resolved the tag will not be written. That will allow for custom tags to be created using certain CloudTrail event fields that may not exist in all CloudTrail event types. Check out the [CloudTrail Log Event Reference](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-event-reference.html) for the most common fields. Also, each AWS resource will have unique fields in the `requestParameters` and `responseElements` fields that can be used. Examples of specific AWS resource CloudTrail events can be found at [CloudTrail Log File Examples](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-log-file-examples.html) or by searching in the CloudTrail event history.
61-
62-
Example:
63-
64-
```json
65-
{
66-
"AutoTag_ManagedBy": "Site Reliability Engineering",
67-
"AutoTag_UserIdentityType": "$event.userIdentity.type",
68-
"AutoTag_UserName": "$event.userIdentity.userName",
69-
"AutoTag_ClientInfo": "SourceIP: $event.sourceIPAddress, UserAgent: $event.userAgent",
70-
"AutoTag_Ec2_ImageId": "$event.responseElements.instancesSet.items.0.imageId"
71-
}
72-
```
73-
7474
#### Commands and Options
7575

7676
```text
@@ -106,7 +106,7 @@ Follow these steps to prepare to run the `create` command.
106106
2. Pick a dedicated AutoTag `--s3-bucket` name, e.g. 'acme-autotag'
107107
3. Configure AWS credentials for the AWS CLI, see [Configure AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html)
108108

109-
#### Deployment
109+
#### Deployment Examples
110110

111111
Download the latest version of `deploy_autotag.sh`, or find it in the root of the repository.
112112

deploy_autotag.sh

+9-5
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,9 @@ function update-stacks () {
359359
(
360360
cd "$TEMP_DIR"
361361
git clone --depth 1 "https://github.com/$REPO_NAME.git"
362-
cd auto-tag
362+
echo
363363

364+
cd auto-tag
364365
npm install
365366

366367
build-package 'master'
@@ -486,7 +487,7 @@ function command_exists () {
486487
type "$1" &> /dev/null ;
487488
}
488489

489-
function check-dependencies () {
490+
function check-min-dependencies () {
490491

491492
if [ "${BASH_VERSINFO[0]}" -lt "$MIN_BASH_VERSION" ] ; then
492493
echo "Bash version $BASH_VERSION is unsupported, Bash must be at version $MIN_BASH_VERSION or greater."
@@ -557,7 +558,10 @@ function check-dependencies () {
557558
fi
558559
fi
559560
fi
561+
echo
562+
}
560563

564+
function check-build-dependencies () {
561565
# checking for git
562566
if ! command_exists 'git' ; then
563567
echo "Command 'git' is missing, installing it now..."
@@ -616,8 +620,6 @@ function check-dependencies () {
616620
sudo apt install -y zip
617621
fi
618622
fi
619-
620-
echo
621623
}
622624

623625
function show-help {
@@ -767,7 +769,7 @@ fi
767769
[ -z "$INVOKED_BY" ] && export INVOKED_BY=Enabled
768770
[ -z "$CUSTOM_TAGS" ] && export CUSTOM_TAGS=''
769771

770-
check-dependencies
772+
check-min-dependencies
771773

772774
if [ "$COMMAND" == 'create' ] ; then
773775
print-header 'Create Stacks'
@@ -786,10 +788,12 @@ elif [ "$COMMAND" == 'update-release' ] ; then
786788
update-stacks "$RELEASE_VERSION"
787789

788790
elif [ "$COMMAND" == 'update-master' ] ; then
791+
check-build-dependencies
789792
print-header 'Update Stacks from master'
790793
update-stacks 'master'
791794

792795
elif [ "$COMMAND" == 'update-local' ] ; then
796+
check-build-dependencies
793797
print-header 'Update Stacks from the local repo'
794798
update-stacks 'local'
795799

0 commit comments

Comments
 (0)