Datasets:
Commit ·
4f6bdbf
1
Parent(s): cc54442
Add human_reference_dataset/aws-cloudformation-templates/Solutions/
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- human_reference_dataset/aws-cloudformation-templates/Solutions/ADConnector/README.md +50 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/ADConnector/src/.gitignore +3 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/ADConnector/src/adconnector_custom_resource.py +124 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/ADConnector/src/package.sh +36 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/ADConnector/src/requirements.txt +2 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/ADConnector/templates/ADCONNECTOR.cfn.json +1226 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/ADConnector/templates/ADCONNECTOR.cfn.yaml +721 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/README.md +9 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/inline/amazon_linux.json +159 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/inline/amazon_linux.yaml +155 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/inline/centos.json +203 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/inline/centos.yaml +190 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/inline/debian.json +158 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/inline/debian.yaml +172 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/inline/redhat.json +205 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/inline/redhat.yaml +192 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/inline/suse.json +203 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/inline/suse.yaml +189 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/inline/ubuntu.json +158 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/inline/ubuntu.yaml +159 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/inline/windows.json +125 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/inline/windows.yaml +130 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/ssm/amazon_linux.json +180 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/ssm/amazon_linux.yaml +146 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/ssm/centos.json +224 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/ssm/centos.yaml +181 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/ssm/debian.json +179 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/ssm/debian.yaml +163 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/ssm/redhat.json +226 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/ssm/redhat.yaml +183 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/ssm/suse.json +224 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/ssm/suse.yaml +180 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/ssm/ubuntu.json +179 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/ssm/ubuntu.yaml +150 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/ssm/windows.json +146 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/ssm/windows.yaml +116 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/CloudFormationEndpointSignals/README.md +35 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/CloudFormationEndpointSignals/cfn-endpoint-creationpolicy-no-igw.json +309 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/CloudFormationEndpointSignals/cfn-endpoint-creationpolicy-no-igw.yaml +183 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/CloudFormationEndpointSignals/cfn-endpoint-creationpolicy.json +589 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/CloudFormationEndpointSignals/cfn-endpoint-creationpolicy.yaml +340 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/CloudFormationEndpointSignals/cfn-endpoint-waitcondition-no-igw.json +360 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/CloudFormationEndpointSignals/cfn-endpoint-waitcondition-no-igw.yaml +217 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/CloudFormationEndpointSignals/cfn-endpoint-waitcondition.json +640 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/CloudFormationEndpointSignals/cfn-endpoint-waitcondition.yaml +373 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/CloudFrontCustomOriginLambda@Edge/CloudFront.json +1227 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/CloudFrontCustomOriginLambda@Edge/CloudFront.yaml +823 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/CloudFrontCustomOriginLambda@Edge/LICENSE.txt +14 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/CloudFrontCustomOriginLambda@Edge/README.md +30 -0
- human_reference_dataset/aws-cloudformation-templates/Solutions/CodeBuildAndCodePipeline/cloudformation-codebuild-template.json +348 -0
human_reference_dataset/aws-cloudformation-templates/Solutions/ADConnector/README.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# AD Connector
|
| 2 |
+
|
| 3 |
+
## Description
|
| 4 |
+
|
| 5 |
+
This solution creates an AD Connector to connect to an on-premises directory.
|
| 6 |
+
|
| 7 |
+
- (Optional) Create AWS resources (IAM role & instance profile) to support
|
| 8 |
+
seamlessly joining Windows EC2 instances to your AD Connector directory.
|
| 9 |
+
- (Optional) Create AWS resources (IAM role, instance profile, and secret) to
|
| 10 |
+
support seamlessly joining Linux EC2 instances to your AD Connector directory.
|
| 11 |
+
- (Optional) Creates a Domain Members Security Group with **EXAMPLE** rules
|
| 12 |
+
allowing all Private IP communications inbound.
|
| 13 |
+
|
| 14 |
+
## Notes
|
| 15 |
+
|
| 16 |
+
- AD Connector is not an AWS CloudFormation supported resource, therefore using
|
| 17 |
+
an AWS CloudFormation custom resource.
|
| 18 |
+
- CloudWatch Logs Log Group uses Amazon managed server-side encryption.
|
| 19 |
+
Optionally, a KMS CMK can be used.
|
| 20 |
+
- Secrets Manager Secrets using Amazon managed server-side encryption.
|
| 21 |
+
Optionally, a KMS CMK can be used.
|
| 22 |
+
- **NOTE** Security Group rules are configured to allow all inbound
|
| 23 |
+
communications from [RFC1918](https://tools.ietf.org/html/rfc1918#section-3)
|
| 24 |
+
Private Address Space, which includes:
|
| 25 |
+
`10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16`, this is used as an **EXAMPLE**,
|
| 26 |
+
however, all security group rules can be locked down based on the
|
| 27 |
+
requirements.
|
| 28 |
+
|
| 29 |
+
## Resources
|
| 30 |
+
|
| 31 |
+
- [Active Directory Connector](https://docs.aws.amazon.com/directoryservice/latest/admin-guide/directory_ad_connector.html)
|
| 32 |
+
- [AD Connector Prerequisites](https://docs.aws.amazon.com/directoryservice/latest/admin-guide/prereq_connector.html)
|
| 33 |
+
- [Join an EC2 instance to your AD Connector directory](https://docs.aws.amazon.com/directoryservice/latest/admin-guide/ad_connector_join_instance.html)
|
| 34 |
+
|
| 35 |
+
## Attributions
|
| 36 |
+
|
| 37 |
+
Using the
|
| 38 |
+
[aws-cloudformation/custom-resource-heper](https://github.com/aws-cloudformation/custom-resource-helper)
|
| 39 |
+
to handle the AWS CloudFormation Custom Resource responses for the given
|
| 40 |
+
resources.
|
| 41 |
+
|
| 42 |
+
## Instructions
|
| 43 |
+
|
| 44 |
+
1. Run [src/package.sh](src/package.sh) to package the code and dependencies.
|
| 45 |
+
1. Upload the
|
| 46 |
+
[src/adconnector\_custom\_resource.zip](src/adconnector_custom_resource.zip) to
|
| 47 |
+
an S3 bucket, note the bucket name.
|
| 48 |
+
1. Launch the AWS CloudFormation stack using the
|
| 49 |
+
[ADCONNECTOR.cfn.yaml](templates/ADCONNECTOR.cfn.yaml) template file as the
|
| 50 |
+
source.
|
human_reference_dataset/aws-cloudformation-templates/Solutions/ADConnector/src/.gitignore
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.package
|
| 2 |
+
adconnector_custom_resource.zip
|
| 3 |
+
|
human_reference_dataset/aws-cloudformation-templates/Solutions/ADConnector/src/adconnector_custom_resource.py
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Create and configure an ADConnector Directory.
|
| 2 |
+
|
| 3 |
+
Copyright 2021 Amazon Web Services, Inc. or its affiliates. All Rights Reserved.
|
| 4 |
+
This AWS Content is provided subject to the terms of the AWS Customer Agreement available at
|
| 5 |
+
http://aws.amazon.com/agreement or other written agreement between Customer and either
|
| 6 |
+
Amazon Web Services, Inc. or Amazon Web Services EMEA SARL or both.
|
| 7 |
+
"""
|
| 8 |
+
|
| 9 |
+
import json
|
| 10 |
+
import logging
|
| 11 |
+
import os
|
| 12 |
+
|
| 13 |
+
import boto3
|
| 14 |
+
from crhelper import CfnResource
|
| 15 |
+
|
| 16 |
+
# Setup Default Logger
|
| 17 |
+
logger = logging.getLogger(__name__)
|
| 18 |
+
logger.setLevel(logging.INFO)
|
| 19 |
+
logger.setLevel(os.environ.get("LOG_LEVEL", logging.ERROR))
|
| 20 |
+
|
| 21 |
+
# Initialize the helper
|
| 22 |
+
helper = CfnResource(json_logging=False, log_level="DEBUG", boto_level="CRITICAL")
|
| 23 |
+
|
| 24 |
+
try:
|
| 25 |
+
ds_client = boto3.client("ds")
|
| 26 |
+
secretsmanager_client = boto3.client("secretsmanager")
|
| 27 |
+
except Exception as error:
|
| 28 |
+
helper.init_failure(error)
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def get_adconnector_parameters(params: dict) -> dict:
|
| 32 |
+
"""Creates a parameters dictionary for the ds:connect_directory API call to create AD Connector.
|
| 33 |
+
|
| 34 |
+
Args:
|
| 35 |
+
params: event resource properties
|
| 36 |
+
|
| 37 |
+
Returns:
|
| 38 |
+
ADConnector Parameters
|
| 39 |
+
"""
|
| 40 |
+
# Get AD Domain Join Credentials from Secrets Manager
|
| 41 |
+
response = secretsmanager_client.get_secret_value(
|
| 42 |
+
SecretId=params["DOMAIN_JOIN_SECRET_ID"]
|
| 43 |
+
)
|
| 44 |
+
secret = json.loads(response["SecretString"])
|
| 45 |
+
# Create DNS Servers List
|
| 46 |
+
|
| 47 |
+
return {
|
| 48 |
+
"Name": params["DOMAIN_DNS_NAME"],
|
| 49 |
+
"ShortName": params["DOMAIN_NETBIOS_NAME"],
|
| 50 |
+
"Password": secret.get("password"),
|
| 51 |
+
"Description": params["ADCONNECTOR_DESCRIPTION"],
|
| 52 |
+
"Size": params["ADCONNECTOR_SIZE"],
|
| 53 |
+
"ConnectSettings": {
|
| 54 |
+
"VpcId": params["ADCONNECTOR_VPCID"],
|
| 55 |
+
"SubnetIds": [
|
| 56 |
+
params["ADCONNECTOR_SUBNET_ID1"],
|
| 57 |
+
params["ADCONNECTOR_SUBNET_ID2"],
|
| 58 |
+
],
|
| 59 |
+
"CustomerDnsIps": params["DOMAIN_DNS_SERVERS"].split(", "),
|
| 60 |
+
"CustomerUserName": secret.get("username"),
|
| 61 |
+
},
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
@helper.create
|
| 66 |
+
def create(event, _) -> str:
|
| 67 |
+
"""Create Event from AWS CloudFormation.
|
| 68 |
+
|
| 69 |
+
Args:
|
| 70 |
+
event: event data
|
| 71 |
+
context: runtime information
|
| 72 |
+
|
| 73 |
+
Returns:
|
| 74 |
+
ADConnectorDirectoryResourceID
|
| 75 |
+
"""
|
| 76 |
+
logger.info("Create Event")
|
| 77 |
+
logger.info(f"REQUEST RECEIVED: {json.dumps(event, default=str)}")
|
| 78 |
+
adconnector_params = get_adconnector_parameters(event["ResourceProperties"])
|
| 79 |
+
response = ds_client.connect_directory(**adconnector_params)
|
| 80 |
+
logger.info(f"connect_directory_response = {json.dumps(response, default=str)}")
|
| 81 |
+
helper.PhysicalResourceId = response["DirectoryId"]
|
| 82 |
+
return helper.PhysicalResourceId
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
@helper.update
|
| 86 |
+
def update(event, _):
|
| 87 |
+
"""Update Event from AWS CloudFormation.
|
| 88 |
+
|
| 89 |
+
Args:
|
| 90 |
+
event: event data
|
| 91 |
+
context: runtime information
|
| 92 |
+
|
| 93 |
+
"""
|
| 94 |
+
logger.info("Update Event")
|
| 95 |
+
logger.info(f"REQUEST RECEIVED: {json.dumps(event, default=str)}")
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
@helper.delete
|
| 99 |
+
def delete(event, _):
|
| 100 |
+
"""Delete Event from AWS CloudFormation. Deletes the ADConnector Directory.
|
| 101 |
+
|
| 102 |
+
Args:
|
| 103 |
+
event: event data
|
| 104 |
+
context: runtime information
|
| 105 |
+
|
| 106 |
+
"""
|
| 107 |
+
logger.info("Delete Event")
|
| 108 |
+
logger.info(f"REQUEST RECEIVED: {json.dumps(event, default=str)}")
|
| 109 |
+
helper.PhysicalResourceId = event.get("PhysicalResourceId")
|
| 110 |
+
directory_id = helper.PhysicalResourceId
|
| 111 |
+
logger.info(f"directory_id = {directory_id}")
|
| 112 |
+
response = ds_client.delete_directory(DirectoryId=directory_id)
|
| 113 |
+
logger.info(f"delete_directory_response = {json.dumps(response, default=str)}")
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
def lambda_handler(event, context):
|
| 117 |
+
"""Lambda Handler.
|
| 118 |
+
|
| 119 |
+
Args:
|
| 120 |
+
event: event data
|
| 121 |
+
context: runtime information
|
| 122 |
+
"""
|
| 123 |
+
logger.info("....Lambda Handler Started....")
|
| 124 |
+
helper(event, context)
|
human_reference_dataset/aws-cloudformation-templates/Solutions/ADConnector/src/package.sh
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
set -e
|
| 3 |
+
|
| 4 |
+
# Builds a lambda package from a single Python 3 module with pip dependencies.
|
| 5 |
+
# This is a modified version of the AWS packaging instructions:
|
| 6 |
+
# https://docs.aws.amazon.com/lambda/latest/dg/lambda-python-how-to-create-deployment-package.html#python-package-dependencies
|
| 7 |
+
|
| 8 |
+
# Set name of python script, excluding .py extension
|
| 9 |
+
SCRIPT_NAME="adconnector_custom_resource"
|
| 10 |
+
SCRIPT_DIRECTORY=$(pwd)
|
| 11 |
+
|
| 12 |
+
# Clean-Up
|
| 13 |
+
rm -rf .package .DS_Store "$SCRIPT_NAME".zip
|
| 14 |
+
|
| 15 |
+
create_package() {
|
| 16 |
+
# Create .package directory
|
| 17 |
+
mkdir -p .package
|
| 18 |
+
# Add dependencies to .package, per the requirements.txt
|
| 19 |
+
pip3 install --target .package --requirement requirements.txt
|
| 20 |
+
# Add the python script to .package
|
| 21 |
+
cp ./"${SCRIPT_NAME}".py .package
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
# Includes Python Script & Dependencies (if any)
|
| 25 |
+
make_zip() {
|
| 26 |
+
cd .package
|
| 27 |
+
zip -r ../"${SCRIPT_NAME}".zip ./*
|
| 28 |
+
echo -e "\n### SCRIPT DIRECTORY: ${SCRIPT_DIRECTORY}"
|
| 29 |
+
echo -e "\n### LAMBDA ZIP FILE: ${SCRIPT_NAME}.zip"
|
| 30 |
+
cd ..
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
create_package
|
| 34 |
+
make_zip
|
| 35 |
+
|
| 36 |
+
echo -e "### LAMBDA PACKAGE SIZE: $(du -sh .package)"
|
human_reference_dataset/aws-cloudformation-templates/Solutions/ADConnector/src/requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# DEPENDENCIES
|
| 2 |
+
crhelper
|
human_reference_dataset/aws-cloudformation-templates/Solutions/ADConnector/templates/ADCONNECTOR.cfn.json
ADDED
|
@@ -0,0 +1,1226 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"AWSTemplateFormatVersion": "2010-09-09",
|
| 3 |
+
"Description": "This template creates an AD Connector to connect to an on-premises directory. Tasks accomplished, (1) create AD Connector (2) option to create seamless domain join resources for Windows & Linux EC2 instances (3) option to create a domain members security group that allows all PrivateIP communications inbound (4) option to create DHCPOptionSet pointing to Domain DNS servers",
|
| 4 |
+
"Metadata": {
|
| 5 |
+
"cfn-lint": {
|
| 6 |
+
"config": {
|
| 7 |
+
"ignore_checks": [
|
| 8 |
+
"W1001"
|
| 9 |
+
]
|
| 10 |
+
}
|
| 11 |
+
},
|
| 12 |
+
"AWS::CloudFormation::Interface": {
|
| 13 |
+
"ParameterGroups": [
|
| 14 |
+
{
|
| 15 |
+
"Label": "Network Configuration",
|
| 16 |
+
"Parameters": [
|
| 17 |
+
"VPCID",
|
| 18 |
+
"PrivateSubnet1ID",
|
| 19 |
+
"PrivateSubnet2ID",
|
| 20 |
+
"CreateADConnectorDomainMembersSG",
|
| 21 |
+
"CreateDHCPOptionSet"
|
| 22 |
+
]
|
| 23 |
+
},
|
| 24 |
+
{
|
| 25 |
+
"Label": {
|
| 26 |
+
"default": "Active Directory Configuration (Onprem)"
|
| 27 |
+
},
|
| 28 |
+
"Parameters": [
|
| 29 |
+
"DomainDNSName",
|
| 30 |
+
"DomainNetBiosName",
|
| 31 |
+
"DomainJoinUser",
|
| 32 |
+
"DomainJoinUserPassword",
|
| 33 |
+
"DomainDNSServers",
|
| 34 |
+
"SecretsManagerDomainCredentialsSecretsKMSKey"
|
| 35 |
+
]
|
| 36 |
+
},
|
| 37 |
+
{
|
| 38 |
+
"Label": {
|
| 39 |
+
"default": "AD Connector Configuration"
|
| 40 |
+
},
|
| 41 |
+
"Parameters": [
|
| 42 |
+
"ADConnectorSize",
|
| 43 |
+
"ADConnectorDescription",
|
| 44 |
+
"CreateWindowsEC2DomainJoinResources",
|
| 45 |
+
"CreateLinuxEC2DomainJoinResources",
|
| 46 |
+
"SSMLogsBucketName"
|
| 47 |
+
]
|
| 48 |
+
},
|
| 49 |
+
{
|
| 50 |
+
"Label": {
|
| 51 |
+
"default": "Lambda Function Configuration (AD Connector Custom Resource)"
|
| 52 |
+
},
|
| 53 |
+
"Parameters": [
|
| 54 |
+
"LambdaFunctionName",
|
| 55 |
+
"LambdaS3BucketName",
|
| 56 |
+
"LambdaZipFileName",
|
| 57 |
+
"LambdaLogsLogGroupRetention",
|
| 58 |
+
"LambdaLogsCloudWatchKMSKey",
|
| 59 |
+
"LambdaLogLevel"
|
| 60 |
+
]
|
| 61 |
+
}
|
| 62 |
+
],
|
| 63 |
+
"ParameterLabels": {
|
| 64 |
+
"ADConnectorDescription": {
|
| 65 |
+
"default": "AD Connector Description"
|
| 66 |
+
},
|
| 67 |
+
"ADConnectorSize": {
|
| 68 |
+
"default": "AD Connector Size"
|
| 69 |
+
},
|
| 70 |
+
"CreateDHCPOptionSet": {
|
| 71 |
+
"default": "Create DHCP Option Set"
|
| 72 |
+
},
|
| 73 |
+
"CreateADConnectorDomainMembersSG": {
|
| 74 |
+
"default": "Create Domain Members Security Group"
|
| 75 |
+
},
|
| 76 |
+
"CreateLinuxEC2DomainJoinResources": {
|
| 77 |
+
"default": "Create AWS resources to support seamless domain join Linux EC2 instances"
|
| 78 |
+
},
|
| 79 |
+
"CreateWindowsEC2DomainJoinResources": {
|
| 80 |
+
"default": "Create AWS resources to support seamless domain join Windows EC2 instances"
|
| 81 |
+
},
|
| 82 |
+
"DomainDNSName": {
|
| 83 |
+
"default": "Domain DNS Name"
|
| 84 |
+
},
|
| 85 |
+
"DomainDNSServers": {
|
| 86 |
+
"default": "Domain DNS Servers"
|
| 87 |
+
},
|
| 88 |
+
"DomainNetBiosName": {
|
| 89 |
+
"default": "Domain NetBIOS Name"
|
| 90 |
+
},
|
| 91 |
+
"DomainJoinUser": {
|
| 92 |
+
"default": "Domain Join User"
|
| 93 |
+
},
|
| 94 |
+
"DomainJoinUserPassword": {
|
| 95 |
+
"default": "Domain Join User Password"
|
| 96 |
+
},
|
| 97 |
+
"LambdaFunctionName": {
|
| 98 |
+
"default": "Lambda Function Name"
|
| 99 |
+
},
|
| 100 |
+
"LambdaLogLevel": {
|
| 101 |
+
"default": "Lambda Log Level"
|
| 102 |
+
},
|
| 103 |
+
"LambdaLogsLogGroupRetention": {
|
| 104 |
+
"default": "CloudWatch log retention days for Lambda logs"
|
| 105 |
+
},
|
| 106 |
+
"LambdaLogsCloudWatchKMSKey": {
|
| 107 |
+
"default": "CloudWatch Logs KMS Key for Lambda logs"
|
| 108 |
+
},
|
| 109 |
+
"LambdaS3BucketName": {
|
| 110 |
+
"default": "Lambda S3 Bucket Name"
|
| 111 |
+
},
|
| 112 |
+
"LambdaZipFileName": {
|
| 113 |
+
"default": "Lambda Zip File Name"
|
| 114 |
+
},
|
| 115 |
+
"PrivateSubnet1ID": {
|
| 116 |
+
"default": "Private Subnet 1 ID"
|
| 117 |
+
},
|
| 118 |
+
"PrivateSubnet2ID": {
|
| 119 |
+
"default": "Private Subnet 2 ID"
|
| 120 |
+
},
|
| 121 |
+
"SecretsManagerDomainCredentialsSecretsKMSKey": {
|
| 122 |
+
"default": "Secrets Manager KMS Key for domain credentials secret"
|
| 123 |
+
},
|
| 124 |
+
"SSMLogsBucketName": {
|
| 125 |
+
"default": "Systems Manager (SSM) Logs Bucket Name"
|
| 126 |
+
},
|
| 127 |
+
"VPCID": {
|
| 128 |
+
"default": "VPC ID"
|
| 129 |
+
}
|
| 130 |
+
}
|
| 131 |
+
}
|
| 132 |
+
},
|
| 133 |
+
"Parameters": {
|
| 134 |
+
"ADConnectorDescription": {
|
| 135 |
+
"Description": "Description for the directory",
|
| 136 |
+
"Type": "String",
|
| 137 |
+
"Default": "On-premises AD",
|
| 138 |
+
"AllowedPattern": "^[A-Za-z0-9][\\w@#%*+=:?.\\/! -]*$",
|
| 139 |
+
"MaxLength": 128
|
| 140 |
+
},
|
| 141 |
+
"ADConnectorSize": {
|
| 142 |
+
"Description": "Size of the directory",
|
| 143 |
+
"Type": "String",
|
| 144 |
+
"AllowedValues": [
|
| 145 |
+
"Small",
|
| 146 |
+
"Large"
|
| 147 |
+
],
|
| 148 |
+
"Default": "Small"
|
| 149 |
+
},
|
| 150 |
+
"CreateDHCPOptionSet": {
|
| 151 |
+
"Description": "Create DHCP Option Set",
|
| 152 |
+
"Type": "String",
|
| 153 |
+
"AllowedValues": [
|
| 154 |
+
"Yes",
|
| 155 |
+
"No"
|
| 156 |
+
],
|
| 157 |
+
"Default": "No"
|
| 158 |
+
},
|
| 159 |
+
"CreateADConnectorDomainMembersSG": {
|
| 160 |
+
"Description": "Create Domain Members Security Group. Note, using allow any type rules, restrict accordingly.",
|
| 161 |
+
"Type": "String",
|
| 162 |
+
"AllowedValues": [
|
| 163 |
+
"Yes",
|
| 164 |
+
"No"
|
| 165 |
+
],
|
| 166 |
+
"Default": "No"
|
| 167 |
+
},
|
| 168 |
+
"CreateLinuxEC2DomainJoinResources": {
|
| 169 |
+
"Description": "Create AWS resources (IAM role, instance profile, & secret) to support seamless domain join Linux EC2 instances",
|
| 170 |
+
"Type": "String",
|
| 171 |
+
"AllowedValues": [
|
| 172 |
+
"Yes",
|
| 173 |
+
"No"
|
| 174 |
+
],
|
| 175 |
+
"Default": "No"
|
| 176 |
+
},
|
| 177 |
+
"CreateWindowsEC2DomainJoinResources": {
|
| 178 |
+
"Description": "Create AWS resources (IAM role & instnace profile)to support seamless domain join Windows EC2 instances",
|
| 179 |
+
"Type": "String",
|
| 180 |
+
"AllowedValues": [
|
| 181 |
+
"Yes",
|
| 182 |
+
"No"
|
| 183 |
+
],
|
| 184 |
+
"Default": "No"
|
| 185 |
+
},
|
| 186 |
+
"DomainDNSName": {
|
| 187 |
+
"Description": "Fully qualified name of the on-premises directory, such as corp.example.com",
|
| 188 |
+
"Type": "String",
|
| 189 |
+
"AllowedPattern": "[a-zA-Z0-9-]+\\..+",
|
| 190 |
+
"MaxLength": 25,
|
| 191 |
+
"MinLength": 3
|
| 192 |
+
},
|
| 193 |
+
"DomainDNSServers": {
|
| 194 |
+
"Description": "DNS or domain controller servers for the on-premises directory.",
|
| 195 |
+
"Type": "String",
|
| 196 |
+
"AllowedPattern": "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$|^((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(,|, ))*(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$",
|
| 197 |
+
"ConstraintDescription": "Must be in the form of IP address. Additional IP addresses can be provided, separated by a \"comma\". (e.g., 10.1.1.1,10.2.2.2) Additional IP addresses can be provided, separated by a \"comma\"."
|
| 198 |
+
},
|
| 199 |
+
"DomainNetBiosName": {
|
| 200 |
+
"Description": "Short name of your existing directory, such as CORP",
|
| 201 |
+
"Type": "String",
|
| 202 |
+
"AllowedPattern": "[a-zA-Z0-9-]+",
|
| 203 |
+
"MaxLength": 15,
|
| 204 |
+
"MinLength": 1
|
| 205 |
+
},
|
| 206 |
+
"DomainJoinUser": {
|
| 207 |
+
"Description": "Username of a user in the existing directory",
|
| 208 |
+
"Type": "String",
|
| 209 |
+
"AllowedPattern": "[a-zA-Z0-9]*",
|
| 210 |
+
"MaxLength": 25,
|
| 211 |
+
"MinLength": 5
|
| 212 |
+
},
|
| 213 |
+
"DomainJoinUserPassword": {
|
| 214 |
+
"Description": "Password for the existing user account",
|
| 215 |
+
"Type": "String",
|
| 216 |
+
"AllowedPattern": "(?=^.{6,255}$)((?=.*\\d)(?=.*[A-Z])(?=.*[a-z])|(?=.*\\d)(?=.*[^A-Za-z0-9])(?=.*[a-z])|(?=.*[^A-Za-z0-9])(?=.*[A-Z])(?=.*[a-z])|(?=.*\\d)(?=.*[A-Z])(?=.*[^A-Za-z0-9]))^.*",
|
| 217 |
+
"MaxLength": 32,
|
| 218 |
+
"MinLength": 8,
|
| 219 |
+
"NoEcho": true
|
| 220 |
+
},
|
| 221 |
+
"LambdaFunctionName": {
|
| 222 |
+
"Description": "Lambda Function Name for Custom Resource.",
|
| 223 |
+
"Type": "String",
|
| 224 |
+
"Default": "CR-ADConnector",
|
| 225 |
+
"AllowedPattern": "^[\\w-]{1,64}$",
|
| 226 |
+
"ConstraintDescription": "Max 64 alphanumeric characters. Also special characters supported [_, -]"
|
| 227 |
+
},
|
| 228 |
+
"LambdaLogLevel": {
|
| 229 |
+
"Description": "Lambda logging level",
|
| 230 |
+
"Type": "String",
|
| 231 |
+
"AllowedValues": [
|
| 232 |
+
"INFO",
|
| 233 |
+
"DEBUG"
|
| 234 |
+
],
|
| 235 |
+
"Default": "INFO"
|
| 236 |
+
},
|
| 237 |
+
"LambdaLogsLogGroupRetention": {
|
| 238 |
+
"Description": "Specifies the number of days you want to retain Lambda log events in the CloudWatch Logs",
|
| 239 |
+
"Type": "String",
|
| 240 |
+
"AllowedValues": [
|
| 241 |
+
1,
|
| 242 |
+
3,
|
| 243 |
+
5,
|
| 244 |
+
7,
|
| 245 |
+
14,
|
| 246 |
+
30,
|
| 247 |
+
60,
|
| 248 |
+
90,
|
| 249 |
+
120,
|
| 250 |
+
150,
|
| 251 |
+
180,
|
| 252 |
+
365,
|
| 253 |
+
400,
|
| 254 |
+
545,
|
| 255 |
+
731,
|
| 256 |
+
1827,
|
| 257 |
+
3653
|
| 258 |
+
],
|
| 259 |
+
"Default": 14
|
| 260 |
+
},
|
| 261 |
+
"LambdaLogsCloudWatchKMSKey": {
|
| 262 |
+
"Description": "(Optional) KMS Key ARN to use for encrypting the Lambda logs data. If empty, encryption is enabled with CloudWatch Logs managing the server-side encryption keys.",
|
| 263 |
+
"Type": "String",
|
| 264 |
+
"AllowedPattern": "^$|^arn:(aws[a-zA-Z-]*){1}:kms:[a-z0-9-]+:\\d{12}:key\\/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$",
|
| 265 |
+
"ConstraintDescription": "Key ARN example: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab"
|
| 266 |
+
},
|
| 267 |
+
"LambdaS3BucketName": {
|
| 268 |
+
"Description": "Lambda S3 bucket name for the Lambda deployment package. Lambda bucket name can include numbers, lowercase letters, uppercase letters, and hyphens (-). It cannot start or end with a hyphen (-).",
|
| 269 |
+
"Type": "String",
|
| 270 |
+
"AllowedPattern": "(?=^.{3,63}$)(?!.*[.-]{2})(?!.*[--]{2})(?!^(?:(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(\\.(?!$)|$)){4}$)(^(([a-z0-9]|[a-z0-9][a-z0-9\\-]*[a-z0-9])\\.)*([a-z0-9]|[a-z0-9][a-z0-9\\-]*[a-z0-9])$)",
|
| 271 |
+
"ConstraintDescription": "Lambda S3 bucket name can include numbers, lowercase letters, uppercase letters, and hyphens (-). It cannot start or end with a hyphen (-)."
|
| 272 |
+
},
|
| 273 |
+
"LambdaZipFileName": {
|
| 274 |
+
"Description": "Amazon S3 key of the deployment package.",
|
| 275 |
+
"Type": "String",
|
| 276 |
+
"Default": "adconnector_custom_resource.zip",
|
| 277 |
+
"MaxLength": 1024,
|
| 278 |
+
"MinLength": 1
|
| 279 |
+
},
|
| 280 |
+
"PrivateSubnet1ID": {
|
| 281 |
+
"Description": "ID of the private subnet 1 in Availability Zone 1 (e.g., subnet-a0246dcd)",
|
| 282 |
+
"Type": "AWS::EC2::Subnet::Id"
|
| 283 |
+
},
|
| 284 |
+
"PrivateSubnet2ID": {
|
| 285 |
+
"Description": "ID of the private subnet 2 in Availability Zone 2 (e.g., subnet-a0246dcd)",
|
| 286 |
+
"Type": "AWS::EC2::Subnet::Id"
|
| 287 |
+
},
|
| 288 |
+
"SecretsManagerDomainCredentialsSecretsKMSKey": {
|
| 289 |
+
"Description": "(Optional) KMS Key ARN to use for encrypting the SecretsManager domain credentials secret. If empty, encryption is enabled with SecretsManager managing the server-side encryption keys.",
|
| 290 |
+
"Type": "String",
|
| 291 |
+
"AllowedPattern": "^$|^arn:(aws[a-zA-Z-]*)?:kms:[a-z0-9-]+:\\d{12}:key\\/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$",
|
| 292 |
+
"ConstraintDescription": "Key ARN example: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab"
|
| 293 |
+
},
|
| 294 |
+
"SSMLogsBucketName": {
|
| 295 |
+
"Description": "(Optional) SSM Logs bucket name for where Systems Manager logs should store log files. SSM Logs bucket name can include numbers, lowercase letters, uppercase letters, and hyphens (-). It cannot start or end with a hyphen (-).",
|
| 296 |
+
"Type": "String",
|
| 297 |
+
"Default": "",
|
| 298 |
+
"AllowedPattern": "^$|(?=^.{3,63}$)(?!.*[.-]{2})(?!.*[--]{2})(?!^(?:(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(\\.(?!$)|$)){4}$)(^(([a-z0-9]|[a-z0-9][a-z0-9\\-]*[a-z0-9])\\.)*([a-z0-9]|[a-z0-9][a-z0-9\\-]*[a-z0-9])$)",
|
| 299 |
+
"ConstraintDescription": "SSM Logs bucket name can include numbers, lowercase letters, uppercase letters, and hyphens (-). It cannot start or end with a hyphen (-)."
|
| 300 |
+
},
|
| 301 |
+
"VPCID": {
|
| 302 |
+
"Description": "ID of the VPC (e.g., vpc-0343606e)",
|
| 303 |
+
"Type": "AWS::EC2::VPC::Id"
|
| 304 |
+
}
|
| 305 |
+
},
|
| 306 |
+
"Conditions": {
|
| 307 |
+
"DHCPOptionSetCondition": {
|
| 308 |
+
"Fn::Equals": [
|
| 309 |
+
{
|
| 310 |
+
"Ref": "CreateDHCPOptionSet"
|
| 311 |
+
},
|
| 312 |
+
"Yes"
|
| 313 |
+
]
|
| 314 |
+
},
|
| 315 |
+
"DomainMembersSGCondition": {
|
| 316 |
+
"Fn::Equals": [
|
| 317 |
+
{
|
| 318 |
+
"Ref": "CreateADConnectorDomainMembersSG"
|
| 319 |
+
},
|
| 320 |
+
"Yes"
|
| 321 |
+
]
|
| 322 |
+
},
|
| 323 |
+
"LambdaLogsCloudWatchKMSKeyCondition": {
|
| 324 |
+
"Fn::Not": [
|
| 325 |
+
{
|
| 326 |
+
"Fn::Equals": [
|
| 327 |
+
{
|
| 328 |
+
"Ref": "LambdaLogsCloudWatchKMSKey"
|
| 329 |
+
},
|
| 330 |
+
""
|
| 331 |
+
]
|
| 332 |
+
}
|
| 333 |
+
]
|
| 334 |
+
},
|
| 335 |
+
"LinuxEC2DomainJoinResourcesCondition": {
|
| 336 |
+
"Fn::Equals": [
|
| 337 |
+
{
|
| 338 |
+
"Ref": "CreateLinuxEC2DomainJoinResources"
|
| 339 |
+
},
|
| 340 |
+
"Yes"
|
| 341 |
+
]
|
| 342 |
+
},
|
| 343 |
+
"SecretsManagerDomainCredentialsSecretsKMSKeyCondition": {
|
| 344 |
+
"Fn::Not": [
|
| 345 |
+
{
|
| 346 |
+
"Fn::Equals": [
|
| 347 |
+
{
|
| 348 |
+
"Ref": "SecretsManagerDomainCredentialsSecretsKMSKey"
|
| 349 |
+
},
|
| 350 |
+
""
|
| 351 |
+
]
|
| 352 |
+
}
|
| 353 |
+
]
|
| 354 |
+
},
|
| 355 |
+
"SSMLogsBucketNameCondition": {
|
| 356 |
+
"Fn::Not": [
|
| 357 |
+
{
|
| 358 |
+
"Fn::Equals": [
|
| 359 |
+
{
|
| 360 |
+
"Ref": "SSMLogsBucketName"
|
| 361 |
+
},
|
| 362 |
+
""
|
| 363 |
+
]
|
| 364 |
+
}
|
| 365 |
+
]
|
| 366 |
+
},
|
| 367 |
+
"WindowsEC2DomainJoinResourcesCondition": {
|
| 368 |
+
"Fn::Equals": [
|
| 369 |
+
{
|
| 370 |
+
"Ref": "CreateWindowsEC2DomainJoinResources"
|
| 371 |
+
},
|
| 372 |
+
"Yes"
|
| 373 |
+
]
|
| 374 |
+
}
|
| 375 |
+
},
|
| 376 |
+
"Resources": {
|
| 377 |
+
"ADConnectorDomainMembersSG": {
|
| 378 |
+
"Type": "AWS::EC2::SecurityGroup",
|
| 379 |
+
"Metadata": {
|
| 380 |
+
"cfn_nag": {
|
| 381 |
+
"rules_to_suppress": [
|
| 382 |
+
{
|
| 383 |
+
"id": "W42",
|
| 384 |
+
"reason": "Allow all inbound communications from Private IP CIDRs (for Lab purposes)"
|
| 385 |
+
},
|
| 386 |
+
{
|
| 387 |
+
"id": "W40",
|
| 388 |
+
"reason": "Allow all outbound communications (for Lab purposes)"
|
| 389 |
+
},
|
| 390 |
+
{
|
| 391 |
+
"id": "W5",
|
| 392 |
+
"reason": "Allow all outbound communications (for Lab purposes)"
|
| 393 |
+
},
|
| 394 |
+
{
|
| 395 |
+
"id": "W9",
|
| 396 |
+
"reason": "Allow all inbound communications from Private IP CIDRs (for Lab purposes)"
|
| 397 |
+
}
|
| 398 |
+
]
|
| 399 |
+
}
|
| 400 |
+
},
|
| 401 |
+
"Properties": {
|
| 402 |
+
"GroupDescription": {
|
| 403 |
+
"Fn::Sub": "${DomainNetBiosName} Domain Members SG via AD Connector"
|
| 404 |
+
},
|
| 405 |
+
"VpcId": {
|
| 406 |
+
"Ref": "VPCID"
|
| 407 |
+
},
|
| 408 |
+
"SecurityGroupIngress": [
|
| 409 |
+
{
|
| 410 |
+
"IpProtocol": "-1",
|
| 411 |
+
"Description": "LAB - Allow All Private IP Communications",
|
| 412 |
+
"CidrIp": "10.0.0.0/8"
|
| 413 |
+
},
|
| 414 |
+
{
|
| 415 |
+
"IpProtocol": "-1",
|
| 416 |
+
"Description": "LAB - Allow All Private IP Communications",
|
| 417 |
+
"CidrIp": "172.16.0.0/12"
|
| 418 |
+
},
|
| 419 |
+
{
|
| 420 |
+
"IpProtocol": "-1",
|
| 421 |
+
"Description": "LAB - Allow All Private IP Communications",
|
| 422 |
+
"CidrIp": "192.168.0.0/16"
|
| 423 |
+
}
|
| 424 |
+
],
|
| 425 |
+
"SecurityGroupEgress": [
|
| 426 |
+
{
|
| 427 |
+
"Description": "Allow All Outbound Communications",
|
| 428 |
+
"IpProtocol": "-1",
|
| 429 |
+
"CidrIp": "0.0.0.0/0"
|
| 430 |
+
}
|
| 431 |
+
],
|
| 432 |
+
"Tags": [
|
| 433 |
+
{
|
| 434 |
+
"Key": "Name",
|
| 435 |
+
"Value": {
|
| 436 |
+
"Fn::Sub": "${DomainNetBiosName}-DomainMembersSG-ADConnector"
|
| 437 |
+
}
|
| 438 |
+
}
|
| 439 |
+
]
|
| 440 |
+
},
|
| 441 |
+
"Condition": "DomainMembersSGCondition"
|
| 442 |
+
},
|
| 443 |
+
"ADConnectorLambdaFunction": {
|
| 444 |
+
"Type": "AWS::Lambda::Function",
|
| 445 |
+
"Metadata": {
|
| 446 |
+
"cfn_nag": {
|
| 447 |
+
"rules_to_suppress": [
|
| 448 |
+
{
|
| 449 |
+
"id": "W58",
|
| 450 |
+
"reason": "Permissions to write to CloudWatch Logs provided by the attached IAM role"
|
| 451 |
+
}
|
| 452 |
+
]
|
| 453 |
+
}
|
| 454 |
+
},
|
| 455 |
+
"Properties": {
|
| 456 |
+
"FunctionName": {
|
| 457 |
+
"Ref": "LambdaFunctionName"
|
| 458 |
+
},
|
| 459 |
+
"Handler": "adconnector_custom_resource.lambda_handler",
|
| 460 |
+
"Role": {
|
| 461 |
+
"Fn::GetAtt": [
|
| 462 |
+
"ADConnectorLambdaRole",
|
| 463 |
+
"Arn"
|
| 464 |
+
]
|
| 465 |
+
},
|
| 466 |
+
"Runtime": "python3.8",
|
| 467 |
+
"MemorySize": 128,
|
| 468 |
+
"Timeout": 120,
|
| 469 |
+
"Environment": {
|
| 470 |
+
"Variables": {
|
| 471 |
+
"LOG_LEVEL": {
|
| 472 |
+
"Ref": "LambdaLogLevel"
|
| 473 |
+
}
|
| 474 |
+
}
|
| 475 |
+
},
|
| 476 |
+
"Code": {
|
| 477 |
+
"S3Bucket": {
|
| 478 |
+
"Ref": "LambdaS3BucketName"
|
| 479 |
+
},
|
| 480 |
+
"S3Key": {
|
| 481 |
+
"Ref": "LambdaZipFileName"
|
| 482 |
+
}
|
| 483 |
+
},
|
| 484 |
+
"VpcConfig": {
|
| 485 |
+
"SubnetIds": [
|
| 486 |
+
"PrivateSubnet1ID",
|
| 487 |
+
"PrivateSubnet2ID"
|
| 488 |
+
],
|
| 489 |
+
"SecurityGroupIds": [
|
| 490 |
+
{
|
| 491 |
+
"Ref": "ADConnectorDomainMembersSG"
|
| 492 |
+
}
|
| 493 |
+
]
|
| 494 |
+
}
|
| 495 |
+
}
|
| 496 |
+
},
|
| 497 |
+
"ADConnectorLambdaLogsLogGroup": {
|
| 498 |
+
"DeletionPolicy": "Retain",
|
| 499 |
+
"UpdateReplacePolicy": "Retain",
|
| 500 |
+
"Type": "AWS::Logs::LogGroup",
|
| 501 |
+
"Properties": {
|
| 502 |
+
"LogGroupName": {
|
| 503 |
+
"Fn::Sub": "/aws/lambda/${LambdaFunctionName}"
|
| 504 |
+
},
|
| 505 |
+
"RetentionInDays": {
|
| 506 |
+
"Ref": "LambdaLogsLogGroupRetention"
|
| 507 |
+
},
|
| 508 |
+
"KmsKeyId": {
|
| 509 |
+
"Fn::If": [
|
| 510 |
+
"LambdaLogsCloudWatchKMSKeyCondition",
|
| 511 |
+
{
|
| 512 |
+
"Ref": "LambdaLogsCloudWatchKMSKey"
|
| 513 |
+
},
|
| 514 |
+
{
|
| 515 |
+
"Ref": "AWS::NoValue"
|
| 516 |
+
}
|
| 517 |
+
]
|
| 518 |
+
}
|
| 519 |
+
}
|
| 520 |
+
},
|
| 521 |
+
"ADConnectorLambdaRole": {
|
| 522 |
+
"Type": "AWS::IAM::Role",
|
| 523 |
+
"Metadata": {
|
| 524 |
+
"cfn_nag": {
|
| 525 |
+
"rules_to_suppress": [
|
| 526 |
+
{
|
| 527 |
+
"id": "W11",
|
| 528 |
+
"reason": "Allow * in resource when required"
|
| 529 |
+
},
|
| 530 |
+
{
|
| 531 |
+
"id": "W28",
|
| 532 |
+
"reason": "The role name is defined to identify automation resources"
|
| 533 |
+
}
|
| 534 |
+
]
|
| 535 |
+
}
|
| 536 |
+
},
|
| 537 |
+
"Properties": {
|
| 538 |
+
"RoleName": {
|
| 539 |
+
"Fn::Sub": "${LambdaFunctionName}-LambdaRole"
|
| 540 |
+
},
|
| 541 |
+
"Description": "Rights to Setup AD Connector",
|
| 542 |
+
"AssumeRolePolicyDocument": {
|
| 543 |
+
"Version": "2012-10-17",
|
| 544 |
+
"Statement": [
|
| 545 |
+
{
|
| 546 |
+
"Effect": "Allow",
|
| 547 |
+
"Action": "sts:AssumeRole",
|
| 548 |
+
"Principal": {
|
| 549 |
+
"Service": [
|
| 550 |
+
"lambda.amazonaws.com"
|
| 551 |
+
]
|
| 552 |
+
}
|
| 553 |
+
}
|
| 554 |
+
]
|
| 555 |
+
},
|
| 556 |
+
"Path": "/",
|
| 557 |
+
"Tags": [
|
| 558 |
+
{
|
| 559 |
+
"Key": "StackName",
|
| 560 |
+
"Value": {
|
| 561 |
+
"Ref": "AWS::StackName"
|
| 562 |
+
}
|
| 563 |
+
}
|
| 564 |
+
],
|
| 565 |
+
"Policies": [
|
| 566 |
+
{
|
| 567 |
+
"PolicyName": "CloudWatchLogGroup",
|
| 568 |
+
"PolicyDocument": {
|
| 569 |
+
"Version": "2012-10-17",
|
| 570 |
+
"Statement": [
|
| 571 |
+
{
|
| 572 |
+
"Sid": "CreateLogGroup",
|
| 573 |
+
"Effect": "Allow",
|
| 574 |
+
"Action": "logs:CreateLogGroup",
|
| 575 |
+
"Resource": {
|
| 576 |
+
"Fn::Sub": "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:${ADConnectorLambdaLogsLogGroup}"
|
| 577 |
+
}
|
| 578 |
+
},
|
| 579 |
+
{
|
| 580 |
+
"Sid": "CreateLogStreamAndEvents",
|
| 581 |
+
"Effect": "Allow",
|
| 582 |
+
"Action": [
|
| 583 |
+
"logs:CreateLogStream",
|
| 584 |
+
"logs:PutLogEvents"
|
| 585 |
+
],
|
| 586 |
+
"Resource": {
|
| 587 |
+
"Fn::Sub": "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:${ADConnectorLambdaLogsLogGroup}:log-stream:*"
|
| 588 |
+
}
|
| 589 |
+
}
|
| 590 |
+
]
|
| 591 |
+
}
|
| 592 |
+
},
|
| 593 |
+
{
|
| 594 |
+
"PolicyName": "ADConnector",
|
| 595 |
+
"PolicyDocument": {
|
| 596 |
+
"Version": "2012-10-17",
|
| 597 |
+
"Statement": [
|
| 598 |
+
{
|
| 599 |
+
"Sid": "Directory",
|
| 600 |
+
"Effect": "Allow",
|
| 601 |
+
"Action": [
|
| 602 |
+
"ds:ConnectDirectory",
|
| 603 |
+
"ds:DeleteDirectory"
|
| 604 |
+
],
|
| 605 |
+
"Resource": "*"
|
| 606 |
+
},
|
| 607 |
+
{
|
| 608 |
+
"Sid": "CreateAdConnectorEc2Resources",
|
| 609 |
+
"Effect": "Allow",
|
| 610 |
+
"Action": [
|
| 611 |
+
"ec2:DescribeSubnets",
|
| 612 |
+
"ec2:DescribeVpcs",
|
| 613 |
+
"ec2:CreateSecurityGroup",
|
| 614 |
+
"ec2:CreateNetworkInterface",
|
| 615 |
+
"ec2:DescribeNetworkInterfaces",
|
| 616 |
+
"ec2:AuthorizeSecurityGroupIngress",
|
| 617 |
+
"ec2:AuthorizeSecurityGroupEgress",
|
| 618 |
+
"ec2:CreateTags"
|
| 619 |
+
],
|
| 620 |
+
"Resource": "*",
|
| 621 |
+
"Condition": {
|
| 622 |
+
"Bool": {
|
| 623 |
+
"aws:ViaAWSService": true
|
| 624 |
+
}
|
| 625 |
+
}
|
| 626 |
+
},
|
| 627 |
+
{
|
| 628 |
+
"Sid": "DeleteAdConnectorEc2Resources",
|
| 629 |
+
"Effect": "Allow",
|
| 630 |
+
"Action": [
|
| 631 |
+
"ec2:DeleteSecurityGroup",
|
| 632 |
+
"ec2:DescribeNetworkInterfaces",
|
| 633 |
+
"ec2:DeleteNetworkInterface",
|
| 634 |
+
"ec2:RevokeSecurityGroupIngress",
|
| 635 |
+
"ec2:RevokeSecurityGroupEgress",
|
| 636 |
+
"ec2:DeleteTags"
|
| 637 |
+
],
|
| 638 |
+
"Resource": "*",
|
| 639 |
+
"Condition": {
|
| 640 |
+
"Bool": {
|
| 641 |
+
"aws:ViaAWSService": true
|
| 642 |
+
}
|
| 643 |
+
}
|
| 644 |
+
}
|
| 645 |
+
]
|
| 646 |
+
}
|
| 647 |
+
},
|
| 648 |
+
{
|
| 649 |
+
"PolicyName": "ADConnectorServiceAccountSecret",
|
| 650 |
+
"PolicyDocument": {
|
| 651 |
+
"Version": "2012-10-17",
|
| 652 |
+
"Statement": [
|
| 653 |
+
{
|
| 654 |
+
"Sid": "GetSecret",
|
| 655 |
+
"Effect": "Allow",
|
| 656 |
+
"Action": "secretsmanager:GetSecretValue",
|
| 657 |
+
"Resource": {
|
| 658 |
+
"Ref": "ADConnectorServiceAccountSecret"
|
| 659 |
+
}
|
| 660 |
+
}
|
| 661 |
+
]
|
| 662 |
+
}
|
| 663 |
+
},
|
| 664 |
+
{
|
| 665 |
+
"Fn::If": [
|
| 666 |
+
"SecretsManagerDomainCredentialsSecretsKMSKeyCondition",
|
| 667 |
+
{
|
| 668 |
+
"PolicyName": "KMSKeyForSecret",
|
| 669 |
+
"PolicyDocument": {
|
| 670 |
+
"Version": "2012-10-17",
|
| 671 |
+
"Statement": [
|
| 672 |
+
{
|
| 673 |
+
"Effect": "Allow",
|
| 674 |
+
"Action": "kms:Decrypt",
|
| 675 |
+
"Resource": {
|
| 676 |
+
"Ref": "SecretsManagerDomainCredentialsSecretsKMSKey"
|
| 677 |
+
}
|
| 678 |
+
}
|
| 679 |
+
]
|
| 680 |
+
}
|
| 681 |
+
},
|
| 682 |
+
{
|
| 683 |
+
"Ref": "AWS::NoValue"
|
| 684 |
+
}
|
| 685 |
+
]
|
| 686 |
+
}
|
| 687 |
+
]
|
| 688 |
+
}
|
| 689 |
+
},
|
| 690 |
+
"ADConnectorLinuxEC2DomainJoinInstanceProfile": {
|
| 691 |
+
"Type": "AWS::IAM::InstanceProfile",
|
| 692 |
+
"Properties": {
|
| 693 |
+
"InstanceProfileName": {
|
| 694 |
+
"Ref": "ADConnectorLinuxEC2DomainJoinRole"
|
| 695 |
+
},
|
| 696 |
+
"Path": "/",
|
| 697 |
+
"Roles": [
|
| 698 |
+
{
|
| 699 |
+
"Ref": "ADConnectorLinuxEC2DomainJoinRole"
|
| 700 |
+
}
|
| 701 |
+
]
|
| 702 |
+
},
|
| 703 |
+
"Condition": "LinuxEC2DomainJoinResourcesCondition"
|
| 704 |
+
},
|
| 705 |
+
"ADConnectorLinuxEC2DomainJoinRole": {
|
| 706 |
+
"Type": "AWS::IAM::Role",
|
| 707 |
+
"Metadata": {
|
| 708 |
+
"cfn_nag": {
|
| 709 |
+
"rules_to_suppress": [
|
| 710 |
+
{
|
| 711 |
+
"id": "W28",
|
| 712 |
+
"reason": "The role name is defined to identify automation resources"
|
| 713 |
+
}
|
| 714 |
+
]
|
| 715 |
+
}
|
| 716 |
+
},
|
| 717 |
+
"Properties": {
|
| 718 |
+
"RoleName": {
|
| 719 |
+
"Fn::Sub": "${DomainNetBiosName}-LinuxEC2DomainJoinRole-ADConnector"
|
| 720 |
+
},
|
| 721 |
+
"Description": {
|
| 722 |
+
"Fn::Sub": "IAM Role to Seamlessly Join Linux EC2 Instances to ${DomainNetBiosName} Domain via AD Connector"
|
| 723 |
+
},
|
| 724 |
+
"AssumeRolePolicyDocument": {
|
| 725 |
+
"Version": "2012-10-17",
|
| 726 |
+
"Statement": [
|
| 727 |
+
{
|
| 728 |
+
"Effect": "Allow",
|
| 729 |
+
"Action": "sts:AssumeRole",
|
| 730 |
+
"Principal": {
|
| 731 |
+
"Service": [
|
| 732 |
+
"ec2.amazonaws.com"
|
| 733 |
+
]
|
| 734 |
+
}
|
| 735 |
+
}
|
| 736 |
+
]
|
| 737 |
+
},
|
| 738 |
+
"ManagedPolicyArns": [
|
| 739 |
+
{
|
| 740 |
+
"Fn::Sub": "arn:${AWS::Partition}:iam::aws:policy/AmazonSSMManagedInstanceCore"
|
| 741 |
+
},
|
| 742 |
+
{
|
| 743 |
+
"Fn::Sub": "arn:${AWS::Partition}:iam::aws:policy/AmazonSSMDirectoryServiceAccess"
|
| 744 |
+
}
|
| 745 |
+
],
|
| 746 |
+
"Path": "/",
|
| 747 |
+
"Tags": [
|
| 748 |
+
{
|
| 749 |
+
"Key": "StackName",
|
| 750 |
+
"Value": {
|
| 751 |
+
"Ref": "AWS::StackName"
|
| 752 |
+
}
|
| 753 |
+
}
|
| 754 |
+
],
|
| 755 |
+
"Policies": [
|
| 756 |
+
{
|
| 757 |
+
"PolicyName": "SSMAgent",
|
| 758 |
+
"PolicyDocument": {
|
| 759 |
+
"Version": "2012-10-17",
|
| 760 |
+
"Statement": [
|
| 761 |
+
{
|
| 762 |
+
"Effect": "Allow",
|
| 763 |
+
"Action": "s3:GetObject",
|
| 764 |
+
"Resource": [
|
| 765 |
+
{
|
| 766 |
+
"Fn::Sub": "arn:${AWS::Partition}:s3:::aws-ssm-${AWS::Region}/*"
|
| 767 |
+
},
|
| 768 |
+
{
|
| 769 |
+
"Fn::Sub": "arn:${AWS::Partition}:s3:::aws-windows-downloads-${AWS::Region}/*"
|
| 770 |
+
},
|
| 771 |
+
{
|
| 772 |
+
"Fn::Sub": "arn:${AWS::Partition}:s3:::amazon-ssm-${AWS::Region}/*"
|
| 773 |
+
},
|
| 774 |
+
{
|
| 775 |
+
"Fn::Sub": "arn:${AWS::Partition}:s3:::amazon-ssm-packages-${AWS::Region}/*"
|
| 776 |
+
},
|
| 777 |
+
{
|
| 778 |
+
"Fn::Sub": "arn:${AWS::Partition}:s3:::${AWS::Region}-birdwatcher-prod/*"
|
| 779 |
+
},
|
| 780 |
+
{
|
| 781 |
+
"Fn::Sub": "arn:${AWS::Partition}:s3:::patch-baseline-snapshot-${AWS::Region}/*"
|
| 782 |
+
},
|
| 783 |
+
{
|
| 784 |
+
"Fn::Sub": "arn:${AWS::Partition}:s3:::aws-ssm-distributor-file-${AWS::Region}/*"
|
| 785 |
+
},
|
| 786 |
+
{
|
| 787 |
+
"Fn::Sub": "arn:${AWS::Partition}:s3:::aws-ssm-document-attachments-${AWS::Region}/*"
|
| 788 |
+
}
|
| 789 |
+
]
|
| 790 |
+
}
|
| 791 |
+
]
|
| 792 |
+
}
|
| 793 |
+
},
|
| 794 |
+
{
|
| 795 |
+
"Fn::If": [
|
| 796 |
+
"SSMLogsBucketNameCondition",
|
| 797 |
+
{
|
| 798 |
+
"PolicyName": "SsmLogs",
|
| 799 |
+
"PolicyDocument": {
|
| 800 |
+
"Version": "2012-10-17",
|
| 801 |
+
"Statement": [
|
| 802 |
+
{
|
| 803 |
+
"Effect": "Allow",
|
| 804 |
+
"Action": [
|
| 805 |
+
"s3:GetObject",
|
| 806 |
+
"s3:PutObject",
|
| 807 |
+
"s3:PutObjectAcl",
|
| 808 |
+
"s3:GetEncryptionConfiguration"
|
| 809 |
+
],
|
| 810 |
+
"Resource": [
|
| 811 |
+
{
|
| 812 |
+
"Fn::Sub": "arn:${AWS::Partition}:s3:::${SSMLogsBucketName}"
|
| 813 |
+
},
|
| 814 |
+
{
|
| 815 |
+
"Fn::Sub": "arn:${AWS::Partition}:s3:::${SSMLogsBucketName}/*"
|
| 816 |
+
}
|
| 817 |
+
]
|
| 818 |
+
}
|
| 819 |
+
]
|
| 820 |
+
}
|
| 821 |
+
},
|
| 822 |
+
{
|
| 823 |
+
"Ref": "AWS::NoValue"
|
| 824 |
+
}
|
| 825 |
+
]
|
| 826 |
+
},
|
| 827 |
+
{
|
| 828 |
+
"PolicyName": "ADConnectorLinuxEC2SeamlessDomainJoinSecret",
|
| 829 |
+
"PolicyDocument": {
|
| 830 |
+
"Version": "2012-10-17",
|
| 831 |
+
"Statement": [
|
| 832 |
+
{
|
| 833 |
+
"Effect": "Allow",
|
| 834 |
+
"Action": [
|
| 835 |
+
"secretsmanager:GetSecretValue",
|
| 836 |
+
"secretsmanager:DescribeSecret"
|
| 837 |
+
],
|
| 838 |
+
"Resource": {
|
| 839 |
+
"Ref": "ADConnectorLinuxEC2SeamlessDomainJoinSecret"
|
| 840 |
+
}
|
| 841 |
+
}
|
| 842 |
+
]
|
| 843 |
+
}
|
| 844 |
+
},
|
| 845 |
+
{
|
| 846 |
+
"Fn::If": [
|
| 847 |
+
"SecretsManagerDomainCredentialsSecretsKMSKeyCondition",
|
| 848 |
+
{
|
| 849 |
+
"PolicyName": "KMSKeyForSecret",
|
| 850 |
+
"PolicyDocument": {
|
| 851 |
+
"Version": "2012-10-17",
|
| 852 |
+
"Statement": [
|
| 853 |
+
{
|
| 854 |
+
"Effect": "Allow",
|
| 855 |
+
"Action": "kms:Decrypt",
|
| 856 |
+
"Resource": {
|
| 857 |
+
"Ref": "SecretsManagerDomainCredentialsSecretsKMSKey"
|
| 858 |
+
}
|
| 859 |
+
}
|
| 860 |
+
]
|
| 861 |
+
}
|
| 862 |
+
},
|
| 863 |
+
{
|
| 864 |
+
"Ref": "AWS::NoValue"
|
| 865 |
+
}
|
| 866 |
+
]
|
| 867 |
+
}
|
| 868 |
+
]
|
| 869 |
+
},
|
| 870 |
+
"Condition": "LinuxEC2DomainJoinResourcesCondition"
|
| 871 |
+
},
|
| 872 |
+
"ADConnectorLinuxEC2SeamlessDomainJoinSecret": {
|
| 873 |
+
"DeletionPolicy": "Retain",
|
| 874 |
+
"UpdateReplacePolicy": "Retain",
|
| 875 |
+
"Type": "AWS::SecretsManager::Secret",
|
| 876 |
+
"Properties": {
|
| 877 |
+
"Name": {
|
| 878 |
+
"Fn::Sub": "aws/directory-services/${ADConnectorResource}/seamless-domain-join"
|
| 879 |
+
},
|
| 880 |
+
"Description": {
|
| 881 |
+
"Fn::Sub": "AD Credentials for Seamless Domain Join Windows/Linux EC2 instances to ${DomainNetBiosName} Domain via AD Connector"
|
| 882 |
+
},
|
| 883 |
+
"SecretString": {
|
| 884 |
+
"Fn::Sub": "{ \"awsSeamlessDomainUsername\" : \"${DomainJoinUser}\", \"awsSeamlessDomainPassword\" : \"${DomainJoinUserPassword}\" }"
|
| 885 |
+
},
|
| 886 |
+
"KmsKeyId": {
|
| 887 |
+
"Fn::If": [
|
| 888 |
+
"SecretsManagerDomainCredentialsSecretsKMSKeyCondition",
|
| 889 |
+
{
|
| 890 |
+
"Ref": "SecretsManagerDomainCredentialsSecretsKMSKey"
|
| 891 |
+
},
|
| 892 |
+
{
|
| 893 |
+
"Ref": "AWS::NoValue"
|
| 894 |
+
}
|
| 895 |
+
]
|
| 896 |
+
}
|
| 897 |
+
},
|
| 898 |
+
"Condition": "LinuxEC2DomainJoinResourcesCondition"
|
| 899 |
+
},
|
| 900 |
+
"ADConnectorResource": {
|
| 901 |
+
"Type": "Custom::ADConnectorResource",
|
| 902 |
+
"Properties": {
|
| 903 |
+
"ServiceToken": {
|
| 904 |
+
"Fn::GetAtt": [
|
| 905 |
+
"ADConnectorLambdaFunction",
|
| 906 |
+
"Arn"
|
| 907 |
+
]
|
| 908 |
+
},
|
| 909 |
+
"ADCONNECTOR_DESCRIPTION": {
|
| 910 |
+
"Ref": "ADConnectorDescription"
|
| 911 |
+
},
|
| 912 |
+
"ADCONNECTOR_SIZE": {
|
| 913 |
+
"Ref": "ADConnectorSize"
|
| 914 |
+
},
|
| 915 |
+
"ADCONNECTOR_SUBNET_ID1": {
|
| 916 |
+
"Ref": "PrivateSubnet1ID"
|
| 917 |
+
},
|
| 918 |
+
"ADCONNECTOR_SUBNET_ID2": {
|
| 919 |
+
"Ref": "PrivateSubnet2ID"
|
| 920 |
+
},
|
| 921 |
+
"ADCONNECTOR_VPCID": {
|
| 922 |
+
"Ref": "VPCID"
|
| 923 |
+
},
|
| 924 |
+
"DOMAIN_DNS_NAME": {
|
| 925 |
+
"Ref": "DomainDNSName"
|
| 926 |
+
},
|
| 927 |
+
"DOMAIN_DNS_SERVERS": {
|
| 928 |
+
"Ref": "DomainDNSServers"
|
| 929 |
+
},
|
| 930 |
+
"DOMAIN_NETBIOS_NAME": {
|
| 931 |
+
"Ref": "DomainNetBiosName"
|
| 932 |
+
},
|
| 933 |
+
"DOMAIN_JOIN_SECRET_ID": {
|
| 934 |
+
"Ref": "ADConnectorServiceAccountSecret"
|
| 935 |
+
}
|
| 936 |
+
},
|
| 937 |
+
"Version": "1.0"
|
| 938 |
+
},
|
| 939 |
+
"ADConnectorServiceAccountSecret": {
|
| 940 |
+
"DeletionPolicy": "Retain",
|
| 941 |
+
"UpdateReplacePolicy": "Retain",
|
| 942 |
+
"Type": "AWS::SecretsManager::Secret",
|
| 943 |
+
"Properties": {
|
| 944 |
+
"Name": {
|
| 945 |
+
"Fn::Sub": "ADConnector-ServiceAccount-${DomainNetBiosName}-Domain"
|
| 946 |
+
},
|
| 947 |
+
"Description": {
|
| 948 |
+
"Fn::Sub": "ADConnector Service Account for ${DomainNetBiosName} Domain"
|
| 949 |
+
},
|
| 950 |
+
"SecretString": {
|
| 951 |
+
"Fn::Sub": "{ \"username\" : \"${DomainJoinUser}\", \"password\" : \"${DomainJoinUserPassword}\" }"
|
| 952 |
+
},
|
| 953 |
+
"KmsKeyId": {
|
| 954 |
+
"Fn::If": [
|
| 955 |
+
"SecretsManagerDomainCredentialsSecretsKMSKeyCondition",
|
| 956 |
+
{
|
| 957 |
+
"Ref": "SecretsManagerDomainCredentialsSecretsKMSKey"
|
| 958 |
+
},
|
| 959 |
+
{
|
| 960 |
+
"Ref": "AWS::NoValue"
|
| 961 |
+
}
|
| 962 |
+
]
|
| 963 |
+
}
|
| 964 |
+
}
|
| 965 |
+
},
|
| 966 |
+
"ADConnectorWindowsEC2DomainJoinInstanceProfile": {
|
| 967 |
+
"Type": "AWS::IAM::InstanceProfile",
|
| 968 |
+
"Properties": {
|
| 969 |
+
"InstanceProfileName": {
|
| 970 |
+
"Ref": "ADConnectorWindowsEC2DomainJoinRole"
|
| 971 |
+
},
|
| 972 |
+
"Path": "/",
|
| 973 |
+
"Roles": [
|
| 974 |
+
{
|
| 975 |
+
"Ref": "ADConnectorWindowsEC2DomainJoinRole"
|
| 976 |
+
}
|
| 977 |
+
]
|
| 978 |
+
},
|
| 979 |
+
"Condition": "WindowsEC2DomainJoinResourcesCondition"
|
| 980 |
+
},
|
| 981 |
+
"ADConnectorWindowsEC2DomainJoinRole": {
|
| 982 |
+
"Type": "AWS::IAM::Role",
|
| 983 |
+
"Metadata": {
|
| 984 |
+
"cfn_nag": {
|
| 985 |
+
"rules_to_suppress": [
|
| 986 |
+
{
|
| 987 |
+
"id": "W28",
|
| 988 |
+
"reason": "The role name is defined to identify automation resources"
|
| 989 |
+
}
|
| 990 |
+
]
|
| 991 |
+
}
|
| 992 |
+
},
|
| 993 |
+
"Properties": {
|
| 994 |
+
"RoleName": {
|
| 995 |
+
"Fn::Sub": "${DomainNetBiosName}-ADConnector-WindowsEC2DomainJoinRole"
|
| 996 |
+
},
|
| 997 |
+
"Description": {
|
| 998 |
+
"Fn::Sub": "IAM Role to Seamlessly Join Windows EC2 Instances to ${DomainDNSName} Domain via AD Connector"
|
| 999 |
+
},
|
| 1000 |
+
"AssumeRolePolicyDocument": {
|
| 1001 |
+
"Version": "2012-10-17",
|
| 1002 |
+
"Statement": [
|
| 1003 |
+
{
|
| 1004 |
+
"Effect": "Allow",
|
| 1005 |
+
"Action": "sts:AssumeRole",
|
| 1006 |
+
"Principal": {
|
| 1007 |
+
"Service": [
|
| 1008 |
+
"ec2.amazonaws.com"
|
| 1009 |
+
]
|
| 1010 |
+
}
|
| 1011 |
+
}
|
| 1012 |
+
]
|
| 1013 |
+
},
|
| 1014 |
+
"ManagedPolicyArns": [
|
| 1015 |
+
{
|
| 1016 |
+
"Fn::Sub": "arn:${AWS::Partition}:iam::aws:policy/AmazonSSMManagedInstanceCore"
|
| 1017 |
+
},
|
| 1018 |
+
{
|
| 1019 |
+
"Fn::Sub": "arn:${AWS::Partition}:iam::aws:policy/AmazonSSMDirectoryServiceAccess"
|
| 1020 |
+
}
|
| 1021 |
+
],
|
| 1022 |
+
"Path": "/",
|
| 1023 |
+
"Tags": [
|
| 1024 |
+
{
|
| 1025 |
+
"Key": "StackName",
|
| 1026 |
+
"Value": {
|
| 1027 |
+
"Ref": "AWS::StackName"
|
| 1028 |
+
}
|
| 1029 |
+
}
|
| 1030 |
+
],
|
| 1031 |
+
"Policies": [
|
| 1032 |
+
{
|
| 1033 |
+
"PolicyName": "SSMAgent",
|
| 1034 |
+
"PolicyDocument": {
|
| 1035 |
+
"Version": "2012-10-17",
|
| 1036 |
+
"Statement": [
|
| 1037 |
+
{
|
| 1038 |
+
"Effect": "Allow",
|
| 1039 |
+
"Action": "s3:GetObject",
|
| 1040 |
+
"Resource": [
|
| 1041 |
+
{
|
| 1042 |
+
"Fn::Sub": "arn:${AWS::Partition}:s3:::aws-ssm-${AWS::Region}/*"
|
| 1043 |
+
},
|
| 1044 |
+
{
|
| 1045 |
+
"Fn::Sub": "arn:${AWS::Partition}:s3:::aws-windows-downloads-${AWS::Region}/*"
|
| 1046 |
+
},
|
| 1047 |
+
{
|
| 1048 |
+
"Fn::Sub": "arn:${AWS::Partition}:s3:::amazon-ssm-${AWS::Region}/*"
|
| 1049 |
+
},
|
| 1050 |
+
{
|
| 1051 |
+
"Fn::Sub": "arn:${AWS::Partition}:s3:::amazon-ssm-packages-${AWS::Region}/*"
|
| 1052 |
+
},
|
| 1053 |
+
{
|
| 1054 |
+
"Fn::Sub": "arn:${AWS::Partition}:s3:::${AWS::Region}-birdwatcher-prod/*"
|
| 1055 |
+
},
|
| 1056 |
+
{
|
| 1057 |
+
"Fn::Sub": "arn:${AWS::Partition}:s3:::patch-baseline-snapshot-${AWS::Region}/*"
|
| 1058 |
+
},
|
| 1059 |
+
{
|
| 1060 |
+
"Fn::Sub": "arn:${AWS::Partition}:s3:::aws-ssm-distributor-file-${AWS::Region}/*"
|
| 1061 |
+
},
|
| 1062 |
+
{
|
| 1063 |
+
"Fn::Sub": "arn:${AWS::Partition}:s3:::aws-ssm-document-attachments-${AWS::Region}/*"
|
| 1064 |
+
}
|
| 1065 |
+
]
|
| 1066 |
+
}
|
| 1067 |
+
]
|
| 1068 |
+
}
|
| 1069 |
+
},
|
| 1070 |
+
{
|
| 1071 |
+
"Fn::If": [
|
| 1072 |
+
"SSMLogsBucketNameCondition",
|
| 1073 |
+
{
|
| 1074 |
+
"PolicyName": "SsmLogs",
|
| 1075 |
+
"PolicyDocument": {
|
| 1076 |
+
"Version": "2012-10-17",
|
| 1077 |
+
"Statement": [
|
| 1078 |
+
{
|
| 1079 |
+
"Effect": "Allow",
|
| 1080 |
+
"Action": [
|
| 1081 |
+
"s3:GetObject",
|
| 1082 |
+
"s3:PutObject",
|
| 1083 |
+
"s3:PutObjectAcl",
|
| 1084 |
+
"s3:GetEncryptionConfiguration"
|
| 1085 |
+
],
|
| 1086 |
+
"Resource": [
|
| 1087 |
+
{
|
| 1088 |
+
"Fn::Sub": "arn:${AWS::Partition}:s3:::${SSMLogsBucketName}"
|
| 1089 |
+
},
|
| 1090 |
+
{
|
| 1091 |
+
"Fn::Sub": "arn:${AWS::Partition}:s3:::${SSMLogsBucketName}/*"
|
| 1092 |
+
}
|
| 1093 |
+
]
|
| 1094 |
+
}
|
| 1095 |
+
]
|
| 1096 |
+
}
|
| 1097 |
+
},
|
| 1098 |
+
{
|
| 1099 |
+
"Ref": "AWS::NoValue"
|
| 1100 |
+
}
|
| 1101 |
+
]
|
| 1102 |
+
}
|
| 1103 |
+
]
|
| 1104 |
+
},
|
| 1105 |
+
"Condition": "WindowsEC2DomainJoinResourcesCondition"
|
| 1106 |
+
},
|
| 1107 |
+
"DHCPOptions": {
|
| 1108 |
+
"Type": "AWS::EC2::DHCPOptions",
|
| 1109 |
+
"Properties": {
|
| 1110 |
+
"DomainName": {
|
| 1111 |
+
"Ref": "DomainDNSName"
|
| 1112 |
+
},
|
| 1113 |
+
"DomainNameServers": [
|
| 1114 |
+
{
|
| 1115 |
+
"Ref": "DomainDNSServers"
|
| 1116 |
+
}
|
| 1117 |
+
],
|
| 1118 |
+
"Tags": [
|
| 1119 |
+
{
|
| 1120 |
+
"Key": "Name",
|
| 1121 |
+
"Value": {
|
| 1122 |
+
"Ref": "DomainDNSName"
|
| 1123 |
+
}
|
| 1124 |
+
}
|
| 1125 |
+
]
|
| 1126 |
+
},
|
| 1127 |
+
"Condition": "DHCPOptionSetCondition"
|
| 1128 |
+
},
|
| 1129 |
+
"DHCPOptionsVPCAssociation": {
|
| 1130 |
+
"Type": "AWS::EC2::VPCDHCPOptionsAssociation",
|
| 1131 |
+
"Properties": {
|
| 1132 |
+
"VpcId": {
|
| 1133 |
+
"Ref": "VPCID"
|
| 1134 |
+
},
|
| 1135 |
+
"DhcpOptionsId": {
|
| 1136 |
+
"Ref": "DHCPOptions"
|
| 1137 |
+
}
|
| 1138 |
+
},
|
| 1139 |
+
"Condition": "DHCPOptionSetCondition"
|
| 1140 |
+
}
|
| 1141 |
+
},
|
| 1142 |
+
"Outputs": {
|
| 1143 |
+
"ADConnectorDirectoryId": {
|
| 1144 |
+
"Description": "AD Connector Directory ID",
|
| 1145 |
+
"Value": {
|
| 1146 |
+
"Ref": "ADConnectorResource"
|
| 1147 |
+
},
|
| 1148 |
+
"Export": {
|
| 1149 |
+
"Name": {
|
| 1150 |
+
"Fn::Sub": "${AWS::StackName}-ADConnectorDirectoryId"
|
| 1151 |
+
}
|
| 1152 |
+
}
|
| 1153 |
+
},
|
| 1154 |
+
"ADConnectorDirectoryName": {
|
| 1155 |
+
"Description": "AD Connector Directory Name",
|
| 1156 |
+
"Value": {
|
| 1157 |
+
"Ref": "DomainDNSName"
|
| 1158 |
+
},
|
| 1159 |
+
"Export": {
|
| 1160 |
+
"Name": {
|
| 1161 |
+
"Fn::Sub": "${AWS::StackName}-ADConnectorDirectoryName"
|
| 1162 |
+
}
|
| 1163 |
+
}
|
| 1164 |
+
},
|
| 1165 |
+
"ADConnectorADConnectorDomainMembersSG": {
|
| 1166 |
+
"Description": "ADConnector Domain Members Security Group",
|
| 1167 |
+
"Value": {
|
| 1168 |
+
"Ref": "ADConnectorDomainMembersSG"
|
| 1169 |
+
},
|
| 1170 |
+
"Export": {
|
| 1171 |
+
"Name": {
|
| 1172 |
+
"Fn::Sub": "${AWS::StackName}-${DomainNetBiosName}-ADConnectorDomainMembersSG"
|
| 1173 |
+
}
|
| 1174 |
+
},
|
| 1175 |
+
"Condition": "DomainMembersSGCondition"
|
| 1176 |
+
},
|
| 1177 |
+
"ADConnectorWindowsEC2SeamlessDomainJoinInstanceProfile": {
|
| 1178 |
+
"Description": "IAM Instance Profile with SSM Document Rights to Join Windows Computers via AD Connector",
|
| 1179 |
+
"Value": {
|
| 1180 |
+
"Ref": "ADConnectorWindowsEC2DomainJoinInstanceProfile"
|
| 1181 |
+
},
|
| 1182 |
+
"Export": {
|
| 1183 |
+
"Name": {
|
| 1184 |
+
"Fn::Sub": "${AWS::StackName}-${DomainNetBiosName}-ADConnectorWindowsEC2DomainJoinProfile"
|
| 1185 |
+
}
|
| 1186 |
+
},
|
| 1187 |
+
"Condition": "WindowsEC2DomainJoinResourcesCondition"
|
| 1188 |
+
},
|
| 1189 |
+
"ADConnectorWindowsEC2SeamlessDomainJoinRole": {
|
| 1190 |
+
"Description": "IAM Instance Profile with SSM Document Rights to Join Windows Computers via AD Connector",
|
| 1191 |
+
"Value": {
|
| 1192 |
+
"Ref": "ADConnectorWindowsEC2DomainJoinRole"
|
| 1193 |
+
},
|
| 1194 |
+
"Export": {
|
| 1195 |
+
"Name": {
|
| 1196 |
+
"Fn::Sub": "${AWS::StackName}-${DomainNetBiosName}-ADConnectorWindowsEC2DomainJoinRole"
|
| 1197 |
+
}
|
| 1198 |
+
},
|
| 1199 |
+
"Condition": "WindowsEC2DomainJoinResourcesCondition"
|
| 1200 |
+
},
|
| 1201 |
+
"ADConnectorLinuxEC2SeamlessDomainJoinInstanceProfile": {
|
| 1202 |
+
"Description": "IAM Instance Profile with SSM Document Rights to Join Linux Computers via AD Connector",
|
| 1203 |
+
"Value": {
|
| 1204 |
+
"Ref": "ADConnectorLinuxEC2DomainJoinInstanceProfile"
|
| 1205 |
+
},
|
| 1206 |
+
"Export": {
|
| 1207 |
+
"Name": {
|
| 1208 |
+
"Fn::Sub": "${AWS::StackName}-${DomainNetBiosName}-ADConnectorLinuxEC2DomainJoinProfile"
|
| 1209 |
+
}
|
| 1210 |
+
},
|
| 1211 |
+
"Condition": "LinuxEC2DomainJoinResourcesCondition"
|
| 1212 |
+
},
|
| 1213 |
+
"ADConnectorLinuxEC2SeamlessDomainJoinRole": {
|
| 1214 |
+
"Description": "IAM Instance Profile with SSM Document Rights to Join Linux Computers via AD Connector",
|
| 1215 |
+
"Value": {
|
| 1216 |
+
"Ref": "ADConnectorLinuxEC2DomainJoinRole"
|
| 1217 |
+
},
|
| 1218 |
+
"Export": {
|
| 1219 |
+
"Name": {
|
| 1220 |
+
"Fn::Sub": "${AWS::StackName}-${DomainNetBiosName}-ADConnectorLinuxEC2DomainJoinRole"
|
| 1221 |
+
}
|
| 1222 |
+
},
|
| 1223 |
+
"Condition": "LinuxEC2DomainJoinResourcesCondition"
|
| 1224 |
+
}
|
| 1225 |
+
}
|
| 1226 |
+
}
|
human_reference_dataset/aws-cloudformation-templates/Solutions/ADConnector/templates/ADCONNECTOR.cfn.yaml
ADDED
|
@@ -0,0 +1,721 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
AWSTemplateFormatVersion: "2010-09-09"
|
| 2 |
+
|
| 3 |
+
Description: This template creates an AD Connector to connect to an on-premises directory. Tasks accomplished, (1) create AD Connector (2) option to create seamless domain join resources for Windows & Linux EC2 instances (3) option to create a domain members security group that allows all PrivateIP communications inbound (4) option to create DHCPOptionSet pointing to Domain DNS servers
|
| 4 |
+
|
| 5 |
+
Metadata:
|
| 6 |
+
cfn-lint:
|
| 7 |
+
config:
|
| 8 |
+
ignore_checks:
|
| 9 |
+
- W1001
|
| 10 |
+
|
| 11 |
+
AWS::CloudFormation::Interface:
|
| 12 |
+
ParameterGroups:
|
| 13 |
+
- Label: Network Configuration
|
| 14 |
+
Parameters:
|
| 15 |
+
- VPCID
|
| 16 |
+
- PrivateSubnet1ID
|
| 17 |
+
- PrivateSubnet2ID
|
| 18 |
+
- CreateADConnectorDomainMembersSG
|
| 19 |
+
- CreateDHCPOptionSet
|
| 20 |
+
- Label:
|
| 21 |
+
default: Active Directory Configuration (Onprem)
|
| 22 |
+
Parameters:
|
| 23 |
+
- DomainDNSName
|
| 24 |
+
- DomainNetBiosName
|
| 25 |
+
- DomainJoinUser
|
| 26 |
+
- DomainJoinUserPassword
|
| 27 |
+
- DomainDNSServers
|
| 28 |
+
- SecretsManagerDomainCredentialsSecretsKMSKey
|
| 29 |
+
- Label:
|
| 30 |
+
default: AD Connector Configuration
|
| 31 |
+
Parameters:
|
| 32 |
+
- ADConnectorSize
|
| 33 |
+
- ADConnectorDescription
|
| 34 |
+
- CreateWindowsEC2DomainJoinResources
|
| 35 |
+
- CreateLinuxEC2DomainJoinResources
|
| 36 |
+
- SSMLogsBucketName
|
| 37 |
+
- Label:
|
| 38 |
+
default: Lambda Function Configuration (AD Connector Custom Resource)
|
| 39 |
+
Parameters:
|
| 40 |
+
- LambdaFunctionName
|
| 41 |
+
- LambdaS3BucketName
|
| 42 |
+
- LambdaZipFileName
|
| 43 |
+
- LambdaLogsLogGroupRetention
|
| 44 |
+
- LambdaLogsCloudWatchKMSKey
|
| 45 |
+
- LambdaLogLevel
|
| 46 |
+
ParameterLabels:
|
| 47 |
+
ADConnectorDescription:
|
| 48 |
+
default: AD Connector Description
|
| 49 |
+
ADConnectorSize:
|
| 50 |
+
default: AD Connector Size
|
| 51 |
+
CreateDHCPOptionSet:
|
| 52 |
+
default: Create DHCP Option Set
|
| 53 |
+
CreateADConnectorDomainMembersSG:
|
| 54 |
+
default: Create Domain Members Security Group
|
| 55 |
+
CreateLinuxEC2DomainJoinResources:
|
| 56 |
+
default: Create AWS resources to support seamless domain join Linux EC2 instances
|
| 57 |
+
CreateWindowsEC2DomainJoinResources:
|
| 58 |
+
default: Create AWS resources to support seamless domain join Windows EC2 instances
|
| 59 |
+
DomainDNSName:
|
| 60 |
+
default: Domain DNS Name
|
| 61 |
+
DomainDNSServers:
|
| 62 |
+
default: Domain DNS Servers
|
| 63 |
+
DomainNetBiosName:
|
| 64 |
+
default: Domain NetBIOS Name
|
| 65 |
+
DomainJoinUser:
|
| 66 |
+
default: Domain Join User
|
| 67 |
+
DomainJoinUserPassword:
|
| 68 |
+
default: Domain Join User Password
|
| 69 |
+
LambdaFunctionName:
|
| 70 |
+
default: Lambda Function Name
|
| 71 |
+
LambdaLogLevel:
|
| 72 |
+
default: Lambda Log Level
|
| 73 |
+
LambdaLogsLogGroupRetention:
|
| 74 |
+
default: CloudWatch log retention days for Lambda logs
|
| 75 |
+
LambdaLogsCloudWatchKMSKey:
|
| 76 |
+
default: CloudWatch Logs KMS Key for Lambda logs
|
| 77 |
+
LambdaS3BucketName:
|
| 78 |
+
default: Lambda S3 Bucket Name
|
| 79 |
+
LambdaZipFileName:
|
| 80 |
+
default: Lambda Zip File Name
|
| 81 |
+
PrivateSubnet1ID:
|
| 82 |
+
default: Private Subnet 1 ID
|
| 83 |
+
PrivateSubnet2ID:
|
| 84 |
+
default: Private Subnet 2 ID
|
| 85 |
+
SecretsManagerDomainCredentialsSecretsKMSKey:
|
| 86 |
+
default: Secrets Manager KMS Key for domain credentials secret
|
| 87 |
+
SSMLogsBucketName:
|
| 88 |
+
default: Systems Manager (SSM) Logs Bucket Name
|
| 89 |
+
VPCID:
|
| 90 |
+
default: VPC ID
|
| 91 |
+
|
| 92 |
+
Parameters:
|
| 93 |
+
ADConnectorDescription:
|
| 94 |
+
Description: Description for the directory
|
| 95 |
+
Type: String
|
| 96 |
+
Default: On-premises AD
|
| 97 |
+
AllowedPattern: ^[A-Za-z0-9][\w@#%*+=:?.\/! -]*$
|
| 98 |
+
MaxLength: 128
|
| 99 |
+
|
| 100 |
+
ADConnectorSize:
|
| 101 |
+
Description: Size of the directory
|
| 102 |
+
Type: String
|
| 103 |
+
AllowedValues:
|
| 104 |
+
- Small
|
| 105 |
+
- Large
|
| 106 |
+
Default: Small
|
| 107 |
+
|
| 108 |
+
CreateDHCPOptionSet:
|
| 109 |
+
Description: Create DHCP Option Set
|
| 110 |
+
Type: String
|
| 111 |
+
AllowedValues:
|
| 112 |
+
- Yes
|
| 113 |
+
- No
|
| 114 |
+
Default: No
|
| 115 |
+
|
| 116 |
+
CreateADConnectorDomainMembersSG:
|
| 117 |
+
Description: Create Domain Members Security Group. Note, using allow any type rules, restrict accordingly.
|
| 118 |
+
Type: String
|
| 119 |
+
AllowedValues:
|
| 120 |
+
- Yes
|
| 121 |
+
- No
|
| 122 |
+
Default: No
|
| 123 |
+
|
| 124 |
+
CreateLinuxEC2DomainJoinResources:
|
| 125 |
+
Description: Create AWS resources (IAM role, instance profile, & secret) to support seamless domain join Linux EC2 instances
|
| 126 |
+
Type: String
|
| 127 |
+
AllowedValues:
|
| 128 |
+
- Yes
|
| 129 |
+
- No
|
| 130 |
+
Default: No
|
| 131 |
+
|
| 132 |
+
CreateWindowsEC2DomainJoinResources:
|
| 133 |
+
Description: Create AWS resources (IAM role & instnace profile)to support seamless domain join Windows EC2 instances
|
| 134 |
+
Type: String
|
| 135 |
+
AllowedValues:
|
| 136 |
+
- Yes
|
| 137 |
+
- No
|
| 138 |
+
Default: No
|
| 139 |
+
|
| 140 |
+
DomainDNSName:
|
| 141 |
+
Description: Fully qualified name of the on-premises directory, such as corp.example.com
|
| 142 |
+
Type: String
|
| 143 |
+
AllowedPattern: '[a-zA-Z0-9-]+\..+'
|
| 144 |
+
MaxLength: 25
|
| 145 |
+
MinLength: 3
|
| 146 |
+
|
| 147 |
+
DomainDNSServers:
|
| 148 |
+
Description: DNS or domain controller servers for the on-premises directory.
|
| 149 |
+
Type: String
|
| 150 |
+
AllowedPattern: ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$|^((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(,|, ))*(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$
|
| 151 |
+
ConstraintDescription: Must be in the form of IP address. Additional IP addresses can be provided, separated by a "comma". (e.g., 10.1.1.1,10.2.2.2) Additional IP addresses can be provided, separated by a "comma".
|
| 152 |
+
|
| 153 |
+
DomainNetBiosName:
|
| 154 |
+
Description: Short name of your existing directory, such as CORP
|
| 155 |
+
Type: String
|
| 156 |
+
AllowedPattern: '[a-zA-Z0-9-]+'
|
| 157 |
+
MaxLength: 15
|
| 158 |
+
MinLength: 1
|
| 159 |
+
|
| 160 |
+
DomainJoinUser:
|
| 161 |
+
Description: Username of a user in the existing directory
|
| 162 |
+
Type: String
|
| 163 |
+
AllowedPattern: '[a-zA-Z0-9]*'
|
| 164 |
+
MaxLength: 25
|
| 165 |
+
MinLength: 5
|
| 166 |
+
|
| 167 |
+
DomainJoinUserPassword:
|
| 168 |
+
Description: Password for the existing user account
|
| 169 |
+
Type: String
|
| 170 |
+
AllowedPattern: (?=^.{6,255}$)((?=.*\d)(?=.*[A-Z])(?=.*[a-z])|(?=.*\d)(?=.*[^A-Za-z0-9])(?=.*[a-z])|(?=.*[^A-Za-z0-9])(?=.*[A-Z])(?=.*[a-z])|(?=.*\d)(?=.*[A-Z])(?=.*[^A-Za-z0-9]))^.*
|
| 171 |
+
MaxLength: 32
|
| 172 |
+
MinLength: 8
|
| 173 |
+
NoEcho: true
|
| 174 |
+
|
| 175 |
+
LambdaFunctionName:
|
| 176 |
+
Description: Lambda Function Name for Custom Resource.
|
| 177 |
+
Type: String
|
| 178 |
+
Default: CR-ADConnector
|
| 179 |
+
AllowedPattern: ^[\w-]{1,64}$
|
| 180 |
+
ConstraintDescription: Max 64 alphanumeric characters. Also special characters supported [_, -]
|
| 181 |
+
|
| 182 |
+
LambdaLogLevel:
|
| 183 |
+
Description: Lambda logging level
|
| 184 |
+
Type: String
|
| 185 |
+
AllowedValues:
|
| 186 |
+
- INFO
|
| 187 |
+
- DEBUG
|
| 188 |
+
Default: INFO
|
| 189 |
+
|
| 190 |
+
LambdaLogsLogGroupRetention:
|
| 191 |
+
Description: Specifies the number of days you want to retain Lambda log events in the CloudWatch Logs
|
| 192 |
+
Type: String
|
| 193 |
+
AllowedValues:
|
| 194 |
+
- 1
|
| 195 |
+
- 3
|
| 196 |
+
- 5
|
| 197 |
+
- 7
|
| 198 |
+
- 14
|
| 199 |
+
- 30
|
| 200 |
+
- 60
|
| 201 |
+
- 90
|
| 202 |
+
- 120
|
| 203 |
+
- 150
|
| 204 |
+
- 180
|
| 205 |
+
- 365
|
| 206 |
+
- 400
|
| 207 |
+
- 545
|
| 208 |
+
- 731
|
| 209 |
+
- 1827
|
| 210 |
+
- 3653
|
| 211 |
+
Default: 14
|
| 212 |
+
|
| 213 |
+
LambdaLogsCloudWatchKMSKey:
|
| 214 |
+
Description: (Optional) KMS Key ARN to use for encrypting the Lambda logs data. If empty, encryption is enabled with CloudWatch Logs managing the server-side encryption keys.
|
| 215 |
+
Type: String
|
| 216 |
+
AllowedPattern: ^$|^arn:(aws[a-zA-Z-]*){1}:kms:[a-z0-9-]+:\d{12}:key\/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$
|
| 217 |
+
ConstraintDescription: 'Key ARN example: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab'
|
| 218 |
+
|
| 219 |
+
LambdaS3BucketName:
|
| 220 |
+
Description: Lambda S3 bucket name for the Lambda deployment package. Lambda bucket name can include numbers, lowercase letters, uppercase letters, and hyphens (-). It cannot start or end with a hyphen (-).
|
| 221 |
+
Type: String
|
| 222 |
+
AllowedPattern: (?=^.{3,63}$)(?!.*[.-]{2})(?!.*[--]{2})(?!^(?:(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(\.(?!$)|$)){4}$)(^(([a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])\.)*([a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])$)
|
| 223 |
+
ConstraintDescription: Lambda S3 bucket name can include numbers, lowercase letters, uppercase letters, and hyphens (-). It cannot start or end with a hyphen (-).
|
| 224 |
+
|
| 225 |
+
LambdaZipFileName:
|
| 226 |
+
Description: Amazon S3 key of the deployment package.
|
| 227 |
+
Type: String
|
| 228 |
+
Default: adconnector_custom_resource.zip
|
| 229 |
+
MaxLength: 1024
|
| 230 |
+
MinLength: 1
|
| 231 |
+
|
| 232 |
+
PrivateSubnet1ID:
|
| 233 |
+
Description: ID of the private subnet 1 in Availability Zone 1 (e.g., subnet-a0246dcd)
|
| 234 |
+
Type: AWS::EC2::Subnet::Id
|
| 235 |
+
|
| 236 |
+
PrivateSubnet2ID:
|
| 237 |
+
Description: ID of the private subnet 2 in Availability Zone 2 (e.g., subnet-a0246dcd)
|
| 238 |
+
Type: AWS::EC2::Subnet::Id
|
| 239 |
+
|
| 240 |
+
SecretsManagerDomainCredentialsSecretsKMSKey:
|
| 241 |
+
Description: (Optional) KMS Key ARN to use for encrypting the SecretsManager domain credentials secret. If empty, encryption is enabled with SecretsManager managing the server-side encryption keys.
|
| 242 |
+
Type: String
|
| 243 |
+
AllowedPattern: ^$|^arn:(aws[a-zA-Z-]*)?:kms:[a-z0-9-]+:\d{12}:key\/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$
|
| 244 |
+
ConstraintDescription: 'Key ARN example: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab'
|
| 245 |
+
|
| 246 |
+
SSMLogsBucketName:
|
| 247 |
+
Description: (Optional) SSM Logs bucket name for where Systems Manager logs should store log files. SSM Logs bucket name can include numbers, lowercase letters, uppercase letters, and hyphens (-). It cannot start or end with a hyphen (-).
|
| 248 |
+
Type: String
|
| 249 |
+
Default: ""
|
| 250 |
+
AllowedPattern: ^$|(?=^.{3,63}$)(?!.*[.-]{2})(?!.*[--]{2})(?!^(?:(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(\.(?!$)|$)){4}$)(^(([a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])\.)*([a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])$)
|
| 251 |
+
ConstraintDescription: SSM Logs bucket name can include numbers, lowercase letters, uppercase letters, and hyphens (-). It cannot start or end with a hyphen (-).
|
| 252 |
+
|
| 253 |
+
VPCID:
|
| 254 |
+
Description: ID of the VPC (e.g., vpc-0343606e)
|
| 255 |
+
Type: AWS::EC2::VPC::Id
|
| 256 |
+
|
| 257 |
+
Conditions:
|
| 258 |
+
DHCPOptionSetCondition: !Equals
|
| 259 |
+
- !Ref CreateDHCPOptionSet
|
| 260 |
+
- Yes
|
| 261 |
+
|
| 262 |
+
DomainMembersSGCondition: !Equals
|
| 263 |
+
- !Ref CreateADConnectorDomainMembersSG
|
| 264 |
+
- Yes
|
| 265 |
+
|
| 266 |
+
LambdaLogsCloudWatchKMSKeyCondition: !Not
|
| 267 |
+
- !Equals
|
| 268 |
+
- !Ref LambdaLogsCloudWatchKMSKey
|
| 269 |
+
- ""
|
| 270 |
+
|
| 271 |
+
LinuxEC2DomainJoinResourcesCondition: !Equals
|
| 272 |
+
- !Ref CreateLinuxEC2DomainJoinResources
|
| 273 |
+
- Yes
|
| 274 |
+
|
| 275 |
+
SecretsManagerDomainCredentialsSecretsKMSKeyCondition: !Not
|
| 276 |
+
- !Equals
|
| 277 |
+
- !Ref SecretsManagerDomainCredentialsSecretsKMSKey
|
| 278 |
+
- ""
|
| 279 |
+
|
| 280 |
+
SSMLogsBucketNameCondition: !Not
|
| 281 |
+
- !Equals
|
| 282 |
+
- !Ref SSMLogsBucketName
|
| 283 |
+
- ""
|
| 284 |
+
|
| 285 |
+
WindowsEC2DomainJoinResourcesCondition: !Equals
|
| 286 |
+
- !Ref CreateWindowsEC2DomainJoinResources
|
| 287 |
+
- Yes
|
| 288 |
+
|
| 289 |
+
Resources:
|
| 290 |
+
ADConnectorDomainMembersSG:
|
| 291 |
+
Type: AWS::EC2::SecurityGroup
|
| 292 |
+
Metadata:
|
| 293 |
+
cfn_nag:
|
| 294 |
+
rules_to_suppress:
|
| 295 |
+
- id: W42
|
| 296 |
+
reason: Allow all inbound communications from Private IP CIDRs (for Lab purposes)
|
| 297 |
+
- id: W40
|
| 298 |
+
reason: Allow all outbound communications (for Lab purposes)
|
| 299 |
+
- id: W5
|
| 300 |
+
reason: Allow all outbound communications (for Lab purposes)
|
| 301 |
+
- id: W9
|
| 302 |
+
reason: Allow all inbound communications from Private IP CIDRs (for Lab purposes)
|
| 303 |
+
Properties:
|
| 304 |
+
GroupDescription: !Sub ${DomainNetBiosName} Domain Members SG via AD Connector
|
| 305 |
+
VpcId: !Ref VPCID
|
| 306 |
+
SecurityGroupIngress:
|
| 307 |
+
- IpProtocol: "-1"
|
| 308 |
+
Description: LAB - Allow All Private IP Communications
|
| 309 |
+
CidrIp: 10.0.0.0/8
|
| 310 |
+
- IpProtocol: "-1"
|
| 311 |
+
Description: LAB - Allow All Private IP Communications
|
| 312 |
+
CidrIp: 172.16.0.0/12
|
| 313 |
+
- IpProtocol: "-1"
|
| 314 |
+
Description: LAB - Allow All Private IP Communications
|
| 315 |
+
CidrIp: 192.168.0.0/16
|
| 316 |
+
SecurityGroupEgress:
|
| 317 |
+
- Description: Allow All Outbound Communications
|
| 318 |
+
IpProtocol: "-1"
|
| 319 |
+
CidrIp: 0.0.0.0/0
|
| 320 |
+
Tags:
|
| 321 |
+
- Key: Name
|
| 322 |
+
Value: !Sub ${DomainNetBiosName}-DomainMembersSG-ADConnector
|
| 323 |
+
Condition: DomainMembersSGCondition
|
| 324 |
+
|
| 325 |
+
ADConnectorLambdaFunction:
|
| 326 |
+
Type: AWS::Lambda::Function
|
| 327 |
+
Metadata:
|
| 328 |
+
cfn_nag:
|
| 329 |
+
rules_to_suppress:
|
| 330 |
+
- id: W58
|
| 331 |
+
reason: Permissions to write to CloudWatch Logs provided by the attached IAM role
|
| 332 |
+
Properties:
|
| 333 |
+
FunctionName: !Ref LambdaFunctionName
|
| 334 |
+
Handler: adconnector_custom_resource.lambda_handler
|
| 335 |
+
Role: !GetAtt ADConnectorLambdaRole.Arn
|
| 336 |
+
Runtime: python3.8
|
| 337 |
+
MemorySize: 128
|
| 338 |
+
Timeout: 120
|
| 339 |
+
Environment:
|
| 340 |
+
Variables:
|
| 341 |
+
LOG_LEVEL: !Ref LambdaLogLevel
|
| 342 |
+
Code:
|
| 343 |
+
S3Bucket: !Ref LambdaS3BucketName
|
| 344 |
+
S3Key: !Ref LambdaZipFileName
|
| 345 |
+
VpcConfig:
|
| 346 |
+
SubnetIds:
|
| 347 |
+
- PrivateSubnet1ID
|
| 348 |
+
- PrivateSubnet2ID
|
| 349 |
+
SecurityGroupIds:
|
| 350 |
+
- !Ref ADConnectorDomainMembersSG
|
| 351 |
+
|
| 352 |
+
ADConnectorLambdaLogsLogGroup:
|
| 353 |
+
DeletionPolicy: Retain
|
| 354 |
+
UpdateReplacePolicy: Retain
|
| 355 |
+
Type: AWS::Logs::LogGroup
|
| 356 |
+
Properties:
|
| 357 |
+
LogGroupName: !Sub /aws/lambda/${LambdaFunctionName}
|
| 358 |
+
RetentionInDays: !Ref LambdaLogsLogGroupRetention
|
| 359 |
+
KmsKeyId: !If
|
| 360 |
+
- LambdaLogsCloudWatchKMSKeyCondition
|
| 361 |
+
- !Ref LambdaLogsCloudWatchKMSKey
|
| 362 |
+
- !Ref AWS::NoValue
|
| 363 |
+
|
| 364 |
+
ADConnectorLambdaRole:
|
| 365 |
+
Type: AWS::IAM::Role
|
| 366 |
+
Metadata:
|
| 367 |
+
cfn_nag:
|
| 368 |
+
rules_to_suppress:
|
| 369 |
+
- id: W11
|
| 370 |
+
reason: Allow * in resource when required
|
| 371 |
+
- id: W28
|
| 372 |
+
reason: The role name is defined to identify automation resources
|
| 373 |
+
Properties:
|
| 374 |
+
RoleName: !Sub ${LambdaFunctionName}-LambdaRole
|
| 375 |
+
Description: Rights to Setup AD Connector
|
| 376 |
+
AssumeRolePolicyDocument:
|
| 377 |
+
Version: "2012-10-17"
|
| 378 |
+
Statement:
|
| 379 |
+
- Effect: Allow
|
| 380 |
+
Action: sts:AssumeRole
|
| 381 |
+
Principal:
|
| 382 |
+
Service:
|
| 383 |
+
- lambda.amazonaws.com
|
| 384 |
+
Path: /
|
| 385 |
+
Tags:
|
| 386 |
+
- Key: StackName
|
| 387 |
+
Value: !Ref AWS::StackName
|
| 388 |
+
Policies:
|
| 389 |
+
- PolicyName: CloudWatchLogGroup
|
| 390 |
+
PolicyDocument:
|
| 391 |
+
Version: "2012-10-17"
|
| 392 |
+
Statement:
|
| 393 |
+
- Sid: CreateLogGroup
|
| 394 |
+
Effect: Allow
|
| 395 |
+
Action: logs:CreateLogGroup
|
| 396 |
+
Resource: !Sub arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:${ADConnectorLambdaLogsLogGroup}
|
| 397 |
+
- Sid: CreateLogStreamAndEvents
|
| 398 |
+
Effect: Allow
|
| 399 |
+
Action:
|
| 400 |
+
- logs:CreateLogStream
|
| 401 |
+
- logs:PutLogEvents
|
| 402 |
+
Resource: !Sub arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:${ADConnectorLambdaLogsLogGroup}:log-stream:*
|
| 403 |
+
- PolicyName: ADConnector
|
| 404 |
+
PolicyDocument:
|
| 405 |
+
Version: "2012-10-17"
|
| 406 |
+
Statement:
|
| 407 |
+
- Sid: Directory
|
| 408 |
+
Effect: Allow
|
| 409 |
+
Action:
|
| 410 |
+
- ds:ConnectDirectory
|
| 411 |
+
- ds:DeleteDirectory
|
| 412 |
+
Resource: '*'
|
| 413 |
+
- Sid: CreateAdConnectorEc2Resources
|
| 414 |
+
Effect: Allow
|
| 415 |
+
Action:
|
| 416 |
+
- ec2:DescribeSubnets
|
| 417 |
+
- ec2:DescribeVpcs
|
| 418 |
+
- ec2:CreateSecurityGroup
|
| 419 |
+
- ec2:CreateNetworkInterface
|
| 420 |
+
- ec2:DescribeNetworkInterfaces
|
| 421 |
+
- ec2:AuthorizeSecurityGroupIngress
|
| 422 |
+
- ec2:AuthorizeSecurityGroupEgress
|
| 423 |
+
- ec2:CreateTags
|
| 424 |
+
Resource: '*'
|
| 425 |
+
Condition:
|
| 426 |
+
Bool:
|
| 427 |
+
aws:ViaAWSService: true
|
| 428 |
+
- Sid: DeleteAdConnectorEc2Resources
|
| 429 |
+
Effect: Allow
|
| 430 |
+
Action:
|
| 431 |
+
- ec2:DeleteSecurityGroup
|
| 432 |
+
- ec2:DescribeNetworkInterfaces
|
| 433 |
+
- ec2:DeleteNetworkInterface
|
| 434 |
+
- ec2:RevokeSecurityGroupIngress
|
| 435 |
+
- ec2:RevokeSecurityGroupEgress
|
| 436 |
+
- ec2:DeleteTags
|
| 437 |
+
Resource: '*'
|
| 438 |
+
Condition:
|
| 439 |
+
Bool:
|
| 440 |
+
aws:ViaAWSService: true
|
| 441 |
+
- PolicyName: ADConnectorServiceAccountSecret
|
| 442 |
+
PolicyDocument:
|
| 443 |
+
Version: "2012-10-17"
|
| 444 |
+
Statement:
|
| 445 |
+
- Sid: GetSecret
|
| 446 |
+
Effect: Allow
|
| 447 |
+
Action: secretsmanager:GetSecretValue
|
| 448 |
+
Resource: !Ref ADConnectorServiceAccountSecret
|
| 449 |
+
- !If
|
| 450 |
+
- SecretsManagerDomainCredentialsSecretsKMSKeyCondition
|
| 451 |
+
- PolicyName: KMSKeyForSecret
|
| 452 |
+
PolicyDocument:
|
| 453 |
+
Version: "2012-10-17"
|
| 454 |
+
Statement:
|
| 455 |
+
- Effect: Allow
|
| 456 |
+
Action: kms:Decrypt
|
| 457 |
+
Resource: !Ref SecretsManagerDomainCredentialsSecretsKMSKey
|
| 458 |
+
- !Ref AWS::NoValue
|
| 459 |
+
|
| 460 |
+
ADConnectorLinuxEC2DomainJoinInstanceProfile:
|
| 461 |
+
Type: AWS::IAM::InstanceProfile
|
| 462 |
+
Properties:
|
| 463 |
+
InstanceProfileName: !Ref ADConnectorLinuxEC2DomainJoinRole
|
| 464 |
+
Path: /
|
| 465 |
+
Roles:
|
| 466 |
+
- !Ref ADConnectorLinuxEC2DomainJoinRole
|
| 467 |
+
Condition: LinuxEC2DomainJoinResourcesCondition
|
| 468 |
+
|
| 469 |
+
ADConnectorLinuxEC2DomainJoinRole:
|
| 470 |
+
Type: AWS::IAM::Role
|
| 471 |
+
Metadata:
|
| 472 |
+
cfn_nag:
|
| 473 |
+
rules_to_suppress:
|
| 474 |
+
- id: W28
|
| 475 |
+
reason: The role name is defined to identify automation resources
|
| 476 |
+
Properties:
|
| 477 |
+
RoleName: !Sub ${DomainNetBiosName}-LinuxEC2DomainJoinRole-ADConnector
|
| 478 |
+
Description: !Sub IAM Role to Seamlessly Join Linux EC2 Instances to ${DomainNetBiosName} Domain via AD Connector
|
| 479 |
+
AssumeRolePolicyDocument:
|
| 480 |
+
Version: "2012-10-17"
|
| 481 |
+
Statement:
|
| 482 |
+
- Effect: Allow
|
| 483 |
+
Action: sts:AssumeRole
|
| 484 |
+
Principal:
|
| 485 |
+
Service:
|
| 486 |
+
- ec2.amazonaws.com
|
| 487 |
+
ManagedPolicyArns:
|
| 488 |
+
- !Sub arn:${AWS::Partition}:iam::aws:policy/AmazonSSMManagedInstanceCore
|
| 489 |
+
- !Sub arn:${AWS::Partition}:iam::aws:policy/AmazonSSMDirectoryServiceAccess
|
| 490 |
+
Path: /
|
| 491 |
+
Tags:
|
| 492 |
+
- Key: StackName
|
| 493 |
+
Value: !Ref AWS::StackName
|
| 494 |
+
Policies:
|
| 495 |
+
- PolicyName: SSMAgent
|
| 496 |
+
PolicyDocument:
|
| 497 |
+
Version: "2012-10-17"
|
| 498 |
+
Statement:
|
| 499 |
+
- Effect: Allow
|
| 500 |
+
Action: s3:GetObject
|
| 501 |
+
Resource:
|
| 502 |
+
- !Sub arn:${AWS::Partition}:s3:::aws-ssm-${AWS::Region}/*
|
| 503 |
+
- !Sub arn:${AWS::Partition}:s3:::aws-windows-downloads-${AWS::Region}/*
|
| 504 |
+
- !Sub arn:${AWS::Partition}:s3:::amazon-ssm-${AWS::Region}/*
|
| 505 |
+
- !Sub arn:${AWS::Partition}:s3:::amazon-ssm-packages-${AWS::Region}/*
|
| 506 |
+
- !Sub arn:${AWS::Partition}:s3:::${AWS::Region}-birdwatcher-prod/*
|
| 507 |
+
- !Sub arn:${AWS::Partition}:s3:::patch-baseline-snapshot-${AWS::Region}/*
|
| 508 |
+
- !Sub arn:${AWS::Partition}:s3:::aws-ssm-distributor-file-${AWS::Region}/*
|
| 509 |
+
- !Sub arn:${AWS::Partition}:s3:::aws-ssm-document-attachments-${AWS::Region}/*
|
| 510 |
+
- !If
|
| 511 |
+
- SSMLogsBucketNameCondition
|
| 512 |
+
- PolicyName: SsmLogs
|
| 513 |
+
PolicyDocument:
|
| 514 |
+
Version: "2012-10-17"
|
| 515 |
+
Statement:
|
| 516 |
+
- Effect: Allow
|
| 517 |
+
Action:
|
| 518 |
+
- s3:GetObject
|
| 519 |
+
- s3:PutObject
|
| 520 |
+
- s3:PutObjectAcl
|
| 521 |
+
- s3:GetEncryptionConfiguration
|
| 522 |
+
Resource:
|
| 523 |
+
- !Sub arn:${AWS::Partition}:s3:::${SSMLogsBucketName}
|
| 524 |
+
- !Sub arn:${AWS::Partition}:s3:::${SSMLogsBucketName}/*
|
| 525 |
+
- !Ref AWS::NoValue
|
| 526 |
+
- PolicyName: ADConnectorLinuxEC2SeamlessDomainJoinSecret
|
| 527 |
+
PolicyDocument:
|
| 528 |
+
Version: "2012-10-17"
|
| 529 |
+
Statement:
|
| 530 |
+
- Effect: Allow
|
| 531 |
+
Action:
|
| 532 |
+
- secretsmanager:GetSecretValue
|
| 533 |
+
- secretsmanager:DescribeSecret
|
| 534 |
+
Resource: !Ref ADConnectorLinuxEC2SeamlessDomainJoinSecret
|
| 535 |
+
- !If
|
| 536 |
+
- SecretsManagerDomainCredentialsSecretsKMSKeyCondition
|
| 537 |
+
- PolicyName: KMSKeyForSecret
|
| 538 |
+
PolicyDocument:
|
| 539 |
+
Version: "2012-10-17"
|
| 540 |
+
Statement:
|
| 541 |
+
- Effect: Allow
|
| 542 |
+
Action: kms:Decrypt
|
| 543 |
+
Resource: !Ref SecretsManagerDomainCredentialsSecretsKMSKey
|
| 544 |
+
- !Ref AWS::NoValue
|
| 545 |
+
Condition: LinuxEC2DomainJoinResourcesCondition
|
| 546 |
+
|
| 547 |
+
ADConnectorLinuxEC2SeamlessDomainJoinSecret:
|
| 548 |
+
DeletionPolicy: Retain
|
| 549 |
+
UpdateReplacePolicy: Retain
|
| 550 |
+
Type: AWS::SecretsManager::Secret
|
| 551 |
+
Properties:
|
| 552 |
+
Name: !Sub aws/directory-services/${ADConnectorResource}/seamless-domain-join
|
| 553 |
+
Description: !Sub AD Credentials for Seamless Domain Join Windows/Linux EC2 instances to ${DomainNetBiosName} Domain via AD Connector
|
| 554 |
+
SecretString: !Sub '{ "awsSeamlessDomainUsername" : "${DomainJoinUser}", "awsSeamlessDomainPassword" : "${DomainJoinUserPassword}" }'
|
| 555 |
+
KmsKeyId: !If
|
| 556 |
+
- SecretsManagerDomainCredentialsSecretsKMSKeyCondition
|
| 557 |
+
- !Ref SecretsManagerDomainCredentialsSecretsKMSKey
|
| 558 |
+
- !Ref AWS::NoValue
|
| 559 |
+
Condition: LinuxEC2DomainJoinResourcesCondition
|
| 560 |
+
|
| 561 |
+
ADConnectorResource:
|
| 562 |
+
Type: Custom::ADConnectorResource
|
| 563 |
+
Properties:
|
| 564 |
+
ServiceToken: !GetAtt ADConnectorLambdaFunction.Arn
|
| 565 |
+
ADCONNECTOR_DESCRIPTION: !Ref ADConnectorDescription
|
| 566 |
+
ADCONNECTOR_SIZE: !Ref ADConnectorSize
|
| 567 |
+
ADCONNECTOR_SUBNET_ID1: !Ref PrivateSubnet1ID
|
| 568 |
+
ADCONNECTOR_SUBNET_ID2: !Ref PrivateSubnet2ID
|
| 569 |
+
ADCONNECTOR_VPCID: !Ref VPCID
|
| 570 |
+
DOMAIN_DNS_NAME: !Ref DomainDNSName
|
| 571 |
+
DOMAIN_DNS_SERVERS: !Ref DomainDNSServers
|
| 572 |
+
DOMAIN_NETBIOS_NAME: !Ref DomainNetBiosName
|
| 573 |
+
DOMAIN_JOIN_SECRET_ID: !Ref ADConnectorServiceAccountSecret
|
| 574 |
+
Version: "1.0"
|
| 575 |
+
|
| 576 |
+
ADConnectorServiceAccountSecret:
|
| 577 |
+
DeletionPolicy: Retain
|
| 578 |
+
UpdateReplacePolicy: Retain
|
| 579 |
+
Type: AWS::SecretsManager::Secret
|
| 580 |
+
Properties:
|
| 581 |
+
Name: !Sub ADConnector-ServiceAccount-${DomainNetBiosName}-Domain
|
| 582 |
+
Description: !Sub ADConnector Service Account for ${DomainNetBiosName} Domain
|
| 583 |
+
SecretString: !Sub '{ "username" : "${DomainJoinUser}", "password" : "${DomainJoinUserPassword}" }'
|
| 584 |
+
KmsKeyId: !If
|
| 585 |
+
- SecretsManagerDomainCredentialsSecretsKMSKeyCondition
|
| 586 |
+
- !Ref SecretsManagerDomainCredentialsSecretsKMSKey
|
| 587 |
+
- !Ref AWS::NoValue
|
| 588 |
+
|
| 589 |
+
ADConnectorWindowsEC2DomainJoinInstanceProfile:
|
| 590 |
+
Type: AWS::IAM::InstanceProfile
|
| 591 |
+
Properties:
|
| 592 |
+
InstanceProfileName: !Ref ADConnectorWindowsEC2DomainJoinRole
|
| 593 |
+
Path: /
|
| 594 |
+
Roles:
|
| 595 |
+
- !Ref ADConnectorWindowsEC2DomainJoinRole
|
| 596 |
+
Condition: WindowsEC2DomainJoinResourcesCondition
|
| 597 |
+
|
| 598 |
+
ADConnectorWindowsEC2DomainJoinRole:
|
| 599 |
+
Type: AWS::IAM::Role
|
| 600 |
+
Metadata:
|
| 601 |
+
cfn_nag:
|
| 602 |
+
rules_to_suppress:
|
| 603 |
+
- id: W28
|
| 604 |
+
reason: The role name is defined to identify automation resources
|
| 605 |
+
Properties:
|
| 606 |
+
RoleName: !Sub ${DomainNetBiosName}-ADConnector-WindowsEC2DomainJoinRole
|
| 607 |
+
Description: !Sub IAM Role to Seamlessly Join Windows EC2 Instances to ${DomainDNSName} Domain via AD Connector
|
| 608 |
+
AssumeRolePolicyDocument:
|
| 609 |
+
Version: "2012-10-17"
|
| 610 |
+
Statement:
|
| 611 |
+
- Effect: Allow
|
| 612 |
+
Action: sts:AssumeRole
|
| 613 |
+
Principal:
|
| 614 |
+
Service:
|
| 615 |
+
- ec2.amazonaws.com
|
| 616 |
+
ManagedPolicyArns:
|
| 617 |
+
- !Sub arn:${AWS::Partition}:iam::aws:policy/AmazonSSMManagedInstanceCore
|
| 618 |
+
- !Sub arn:${AWS::Partition}:iam::aws:policy/AmazonSSMDirectoryServiceAccess
|
| 619 |
+
Path: /
|
| 620 |
+
Tags:
|
| 621 |
+
- Key: StackName
|
| 622 |
+
Value: !Ref AWS::StackName
|
| 623 |
+
Policies:
|
| 624 |
+
- PolicyName: SSMAgent
|
| 625 |
+
PolicyDocument:
|
| 626 |
+
Version: "2012-10-17"
|
| 627 |
+
Statement:
|
| 628 |
+
- Effect: Allow
|
| 629 |
+
Action: s3:GetObject
|
| 630 |
+
Resource:
|
| 631 |
+
- !Sub arn:${AWS::Partition}:s3:::aws-ssm-${AWS::Region}/*
|
| 632 |
+
- !Sub arn:${AWS::Partition}:s3:::aws-windows-downloads-${AWS::Region}/*
|
| 633 |
+
- !Sub arn:${AWS::Partition}:s3:::amazon-ssm-${AWS::Region}/*
|
| 634 |
+
- !Sub arn:${AWS::Partition}:s3:::amazon-ssm-packages-${AWS::Region}/*
|
| 635 |
+
- !Sub arn:${AWS::Partition}:s3:::${AWS::Region}-birdwatcher-prod/*
|
| 636 |
+
- !Sub arn:${AWS::Partition}:s3:::patch-baseline-snapshot-${AWS::Region}/*
|
| 637 |
+
- !Sub arn:${AWS::Partition}:s3:::aws-ssm-distributor-file-${AWS::Region}/*
|
| 638 |
+
- !Sub arn:${AWS::Partition}:s3:::aws-ssm-document-attachments-${AWS::Region}/*
|
| 639 |
+
- !If
|
| 640 |
+
- SSMLogsBucketNameCondition
|
| 641 |
+
- PolicyName: SsmLogs
|
| 642 |
+
PolicyDocument:
|
| 643 |
+
Version: "2012-10-17"
|
| 644 |
+
Statement:
|
| 645 |
+
- Effect: Allow
|
| 646 |
+
Action:
|
| 647 |
+
- s3:GetObject
|
| 648 |
+
- s3:PutObject
|
| 649 |
+
- s3:PutObjectAcl
|
| 650 |
+
- s3:GetEncryptionConfiguration
|
| 651 |
+
Resource:
|
| 652 |
+
- !Sub arn:${AWS::Partition}:s3:::${SSMLogsBucketName}
|
| 653 |
+
- !Sub arn:${AWS::Partition}:s3:::${SSMLogsBucketName}/*
|
| 654 |
+
- !Ref AWS::NoValue
|
| 655 |
+
Condition: WindowsEC2DomainJoinResourcesCondition
|
| 656 |
+
|
| 657 |
+
DHCPOptions:
|
| 658 |
+
Type: AWS::EC2::DHCPOptions
|
| 659 |
+
Properties:
|
| 660 |
+
DomainName: !Ref DomainDNSName
|
| 661 |
+
DomainNameServers:
|
| 662 |
+
- !Ref DomainDNSServers
|
| 663 |
+
Tags:
|
| 664 |
+
- Key: Name
|
| 665 |
+
Value: !Ref DomainDNSName
|
| 666 |
+
Condition: DHCPOptionSetCondition
|
| 667 |
+
|
| 668 |
+
DHCPOptionsVPCAssociation:
|
| 669 |
+
Type: AWS::EC2::VPCDHCPOptionsAssociation
|
| 670 |
+
Properties:
|
| 671 |
+
VpcId: !Ref VPCID
|
| 672 |
+
DhcpOptionsId: !Ref DHCPOptions
|
| 673 |
+
Condition: DHCPOptionSetCondition
|
| 674 |
+
|
| 675 |
+
Outputs:
|
| 676 |
+
ADConnectorDirectoryId:
|
| 677 |
+
Description: AD Connector Directory ID
|
| 678 |
+
Value: !Ref ADConnectorResource
|
| 679 |
+
Export:
|
| 680 |
+
Name: !Sub ${AWS::StackName}-ADConnectorDirectoryId
|
| 681 |
+
|
| 682 |
+
ADConnectorDirectoryName:
|
| 683 |
+
Description: AD Connector Directory Name
|
| 684 |
+
Value: !Ref DomainDNSName
|
| 685 |
+
Export:
|
| 686 |
+
Name: !Sub ${AWS::StackName}-ADConnectorDirectoryName
|
| 687 |
+
|
| 688 |
+
ADConnectorADConnectorDomainMembersSG:
|
| 689 |
+
Description: ADConnector Domain Members Security Group
|
| 690 |
+
Value: !Ref ADConnectorDomainMembersSG
|
| 691 |
+
Export:
|
| 692 |
+
Name: !Sub ${AWS::StackName}-${DomainNetBiosName}-ADConnectorDomainMembersSG
|
| 693 |
+
Condition: DomainMembersSGCondition
|
| 694 |
+
|
| 695 |
+
ADConnectorWindowsEC2SeamlessDomainJoinInstanceProfile:
|
| 696 |
+
Description: IAM Instance Profile with SSM Document Rights to Join Windows Computers via AD Connector
|
| 697 |
+
Value: !Ref ADConnectorWindowsEC2DomainJoinInstanceProfile
|
| 698 |
+
Export:
|
| 699 |
+
Name: !Sub ${AWS::StackName}-${DomainNetBiosName}-ADConnectorWindowsEC2DomainJoinProfile
|
| 700 |
+
Condition: WindowsEC2DomainJoinResourcesCondition
|
| 701 |
+
|
| 702 |
+
ADConnectorWindowsEC2SeamlessDomainJoinRole:
|
| 703 |
+
Description: IAM Instance Profile with SSM Document Rights to Join Windows Computers via AD Connector
|
| 704 |
+
Value: !Ref ADConnectorWindowsEC2DomainJoinRole
|
| 705 |
+
Export:
|
| 706 |
+
Name: !Sub ${AWS::StackName}-${DomainNetBiosName}-ADConnectorWindowsEC2DomainJoinRole
|
| 707 |
+
Condition: WindowsEC2DomainJoinResourcesCondition
|
| 708 |
+
|
| 709 |
+
ADConnectorLinuxEC2SeamlessDomainJoinInstanceProfile:
|
| 710 |
+
Description: IAM Instance Profile with SSM Document Rights to Join Linux Computers via AD Connector
|
| 711 |
+
Value: !Ref ADConnectorLinuxEC2DomainJoinInstanceProfile
|
| 712 |
+
Export:
|
| 713 |
+
Name: !Sub ${AWS::StackName}-${DomainNetBiosName}-ADConnectorLinuxEC2DomainJoinProfile
|
| 714 |
+
Condition: LinuxEC2DomainJoinResourcesCondition
|
| 715 |
+
|
| 716 |
+
ADConnectorLinuxEC2SeamlessDomainJoinRole:
|
| 717 |
+
Description: IAM Instance Profile with SSM Document Rights to Join Linux Computers via AD Connector
|
| 718 |
+
Value: !Ref ADConnectorLinuxEC2DomainJoinRole
|
| 719 |
+
Export:
|
| 720 |
+
Name: !Sub ${AWS::StackName}-${DomainNetBiosName}-ADConnectorLinuxEC2DomainJoinRole
|
| 721 |
+
Condition: LinuxEC2DomainJoinResourcesCondition
|
human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/README.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Deploy the Amazon CloudWatch agent to Amazon EC2 instances using AWS CloudFormation
|
| 2 |
+
The /inline and /ssm directories include templates to help you install the Amazon CloudWatch agent on Amazon EC2 instances using AWS CloudFormation. You can also use the templates to update the agent configuration after deployment. For more information, see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Agent-CloudFormation-Templates.html.
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
## /inline directory
|
| 6 |
+
The templates in the /inline directory have the CloudWatch agent configuration embedded into the AWS CloudFormation template. You can modify your CloudWatch agent configuration by modifying the template.
|
| 7 |
+
|
| 8 |
+
## /ssm directory
|
| 9 |
+
The templates in the /ssm directory load the agent configuration from Parameter Store. To use these templates, you must first create a configuration file and upload it to Parameter Store.
|
human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/inline/amazon_linux.json
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"AWSTemplateFormatVersion": "2010-09-09",
|
| 3 |
+
"Description": "Template to install CloudWatchAgent on amazon linux. It was validated on amazon linux 2",
|
| 4 |
+
"Parameters": {
|
| 5 |
+
"KeyName": {
|
| 6 |
+
"Description": "Name of an existing EC2 KeyPair to enable SSH access to the instance",
|
| 7 |
+
"Type": "AWS::EC2::KeyPair::KeyName",
|
| 8 |
+
"ConstraintDescription": "must be the name of an existing EC2 KeyPair."
|
| 9 |
+
},
|
| 10 |
+
"InstanceType": {
|
| 11 |
+
"Description": "EC2 instance type",
|
| 12 |
+
"Type": "String",
|
| 13 |
+
"Default": "t3.medium",
|
| 14 |
+
"ConstraintDescription": "must be a valid EC2 instance type."
|
| 15 |
+
},
|
| 16 |
+
"InstanceAMI": {
|
| 17 |
+
"Description": "Managed AMI ID for EC2 Instance",
|
| 18 |
+
"Type": "AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>",
|
| 19 |
+
"Default": "/aws/service/ami-amazon-linux-latest/al2023-ami-kernel-6.1-x86_64"
|
| 20 |
+
},
|
| 21 |
+
"IAMRole": {
|
| 22 |
+
"Description": "EC2 attached IAM role",
|
| 23 |
+
"Type": "String",
|
| 24 |
+
"Default": "CloudWatchAgentAdminRole",
|
| 25 |
+
"ConstraintDescription": "must be an existing IAM role which will be attached to EC2 instance."
|
| 26 |
+
},
|
| 27 |
+
"SSHLocation": {
|
| 28 |
+
"Description": "The IP address range that can be used to SSH to the EC2 instances",
|
| 29 |
+
"Type": "String",
|
| 30 |
+
"Default": "0.0.0.0/0",
|
| 31 |
+
"MinLength": "9",
|
| 32 |
+
"MaxLength": "18",
|
| 33 |
+
"AllowedPattern": "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})",
|
| 34 |
+
"ConstraintDescription": "must be a valid IP CIDR range of the form x.x.x.x/x."
|
| 35 |
+
},
|
| 36 |
+
"SubnetId": {
|
| 37 |
+
"Type": "AWS::EC2::Subnet::Id"
|
| 38 |
+
}
|
| 39 |
+
},
|
| 40 |
+
"Resources": {
|
| 41 |
+
"EC2Instance": {
|
| 42 |
+
"CreationPolicy": {
|
| 43 |
+
"ResourceSignal": {
|
| 44 |
+
"Count": 1,
|
| 45 |
+
"Timeout": "PT15M"
|
| 46 |
+
}
|
| 47 |
+
},
|
| 48 |
+
"Type": "AWS::EC2::Instance",
|
| 49 |
+
"Metadata": {
|
| 50 |
+
"AWS::CloudFormation::Init": {
|
| 51 |
+
"configSets": {
|
| 52 |
+
"default": [
|
| 53 |
+
"01_setupCfnHup",
|
| 54 |
+
"02_config-amazon-cloudwatch-agent",
|
| 55 |
+
"03_restart_amazon-cloudwatch-agent"
|
| 56 |
+
],
|
| 57 |
+
"UpdateEnvironment": [
|
| 58 |
+
"02_config-amazon-cloudwatch-agent",
|
| 59 |
+
"03_restart_amazon-cloudwatch-agent"
|
| 60 |
+
]
|
| 61 |
+
},
|
| 62 |
+
"02_config-amazon-cloudwatch-agent": {
|
| 63 |
+
"files": {
|
| 64 |
+
"/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json": {
|
| 65 |
+
"content": "{\n \"metrics\": {\n \"append_dimensions\": {\n \"AutoScalingGroupName\": \"${!aws:AutoScalingGroupName}\",\n \"ImageId\": \"${!aws:ImageId}\",\n \"InstanceId\": \"${!aws:InstanceId}\",\n \"InstanceType\": \"${!aws:InstanceType}\"\n },\n \"metrics_collected\": {\n \"mem\": {\n \"measurement\": [\n \"mem_used_percent\"\n ]\n },\n \"swap\": {\n \"measurement\": [\n \"swap_used_percent\"\n ]\n }\n }\n }\n}\n"
|
| 66 |
+
}
|
| 67 |
+
}
|
| 68 |
+
},
|
| 69 |
+
"03_restart_amazon-cloudwatch-agent": {
|
| 70 |
+
"commands": {
|
| 71 |
+
"01_stop_service": {
|
| 72 |
+
"command": "/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a stop"
|
| 73 |
+
},
|
| 74 |
+
"02_start_service": {
|
| 75 |
+
"command": "/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json -s"
|
| 76 |
+
}
|
| 77 |
+
}
|
| 78 |
+
},
|
| 79 |
+
"01_setupCfnHup": {
|
| 80 |
+
"files": {
|
| 81 |
+
"/etc/cfn/cfn-hup.conf": {
|
| 82 |
+
"content": {
|
| 83 |
+
"Fn::Sub": "[main]\nstack=${AWS::StackId}\nregion=${AWS::Region}\ninterval=1\n"
|
| 84 |
+
},
|
| 85 |
+
"mode": "000400",
|
| 86 |
+
"owner": "root",
|
| 87 |
+
"group": "root"
|
| 88 |
+
},
|
| 89 |
+
"/etc/cfn/hooks.d/amazon-cloudwatch-agent-auto-reloader.conf": {
|
| 90 |
+
"content": {
|
| 91 |
+
"Fn::Sub": "[cfn-auto-reloader-hook]\ntriggers=post.update\npath=Resources.EC2Instance.Metadata.AWS::CloudFormation::Init.02_config-amazon-cloudwatch-agent\naction=/opt/aws/bin/cfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets UpdateEnvironment\nrunas=root\n"
|
| 92 |
+
},
|
| 93 |
+
"mode": "000400",
|
| 94 |
+
"owner": "root",
|
| 95 |
+
"group": "root"
|
| 96 |
+
},
|
| 97 |
+
"/lib/systemd/system/cfn-hup.service": {
|
| 98 |
+
"content": "[Unit]\nDescription=cfn-hup daemon\n[Service]\nType=simple\nExecStart=/opt/aws/bin/cfn-hup\nRestart=always\n[Install]\nWantedBy=multi-user.target\n"
|
| 99 |
+
}
|
| 100 |
+
},
|
| 101 |
+
"commands": {
|
| 102 |
+
"01enable_cfn_hup": {
|
| 103 |
+
"command": "systemctl enable cfn-hup.service"
|
| 104 |
+
},
|
| 105 |
+
"02start_cfn_hup": {
|
| 106 |
+
"command": "systemctl start cfn-hup.service"
|
| 107 |
+
}
|
| 108 |
+
}
|
| 109 |
+
}
|
| 110 |
+
}
|
| 111 |
+
},
|
| 112 |
+
"Properties": {
|
| 113 |
+
"InstanceType": {
|
| 114 |
+
"Ref": "InstanceType"
|
| 115 |
+
},
|
| 116 |
+
"IamInstanceProfile": {
|
| 117 |
+
"Ref": "IAMRole"
|
| 118 |
+
},
|
| 119 |
+
"KeyName": {
|
| 120 |
+
"Ref": "KeyName"
|
| 121 |
+
},
|
| 122 |
+
"ImageId": {
|
| 123 |
+
"Ref": "InstanceAMI"
|
| 124 |
+
},
|
| 125 |
+
"SubnetId": {
|
| 126 |
+
"Ref": "SubnetId"
|
| 127 |
+
},
|
| 128 |
+
"SecurityGroupIds": [
|
| 129 |
+
{
|
| 130 |
+
|
| 131 |
+
"Fn::GetAtt" : [ "InstanceSecurityGroup", "GroupId" ]
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
],
|
| 135 |
+
"UserData": {
|
| 136 |
+
"Fn::Base64": {
|
| 137 |
+
"Fn::Sub": "#!/bin/bash\nrpm -Uvh https://s3.amazonaws.com/amazoncloudwatch-agent/amazon_linux/amd64/latest/amazon-cloudwatch-agent.rpm\n/opt/aws/bin/cfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets default\n/opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region}\n"
|
| 138 |
+
}
|
| 139 |
+
}
|
| 140 |
+
}
|
| 141 |
+
},
|
| 142 |
+
"InstanceSecurityGroup": {
|
| 143 |
+
"Type": "AWS::EC2::SecurityGroup",
|
| 144 |
+
"Properties": {
|
| 145 |
+
"GroupDescription": "Enable SSH access via port 22",
|
| 146 |
+
"SecurityGroupIngress": [
|
| 147 |
+
{
|
| 148 |
+
"IpProtocol": "tcp",
|
| 149 |
+
"FromPort": "22",
|
| 150 |
+
"ToPort": "22",
|
| 151 |
+
"CidrIp": {
|
| 152 |
+
"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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
AWSTemplateFormatVersion: "2010-09-09"
|
| 2 |
+
|
| 3 |
+
Description: Template to install CloudWatchAgent on amazon linux. It was validated on amazon linux 2
|
| 4 |
+
|
| 5 |
+
Parameters:
|
| 6 |
+
KeyName:
|
| 7 |
+
Description: Name of an existing EC2 KeyPair to enable SSH access to the instance
|
| 8 |
+
Type: AWS::EC2::KeyPair::KeyName
|
| 9 |
+
ConstraintDescription: must be the name of an existing EC2 KeyPair.
|
| 10 |
+
|
| 11 |
+
InstanceType:
|
| 12 |
+
Description: EC2 instance type
|
| 13 |
+
Type: String
|
| 14 |
+
Default: t3.medium
|
| 15 |
+
ConstraintDescription: must be a valid EC2 instance type.
|
| 16 |
+
|
| 17 |
+
InstanceAMI:
|
| 18 |
+
Description: Managed AMI ID for EC2 Instance
|
| 19 |
+
Type: AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>
|
| 20 |
+
Default: /aws/service/ami-amazon-linux-latest/al2023-ami-kernel-6.1-x86_64
|
| 21 |
+
|
| 22 |
+
IAMRole:
|
| 23 |
+
Description: EC2 attached IAM role
|
| 24 |
+
Type: String
|
| 25 |
+
Default: CloudWatchAgentAdminRole
|
| 26 |
+
ConstraintDescription: must be an existing IAM role which will be attached to EC2 instance.
|
| 27 |
+
|
| 28 |
+
SSHLocation:
|
| 29 |
+
Description: The IP address range that can be used to SSH to the EC2 instances
|
| 30 |
+
Type: String
|
| 31 |
+
Default: 0.0.0.0/0
|
| 32 |
+
MinLength: "9"
|
| 33 |
+
MaxLength: "18"
|
| 34 |
+
AllowedPattern: (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/(\d{1,2})
|
| 35 |
+
ConstraintDescription: must be a valid IP CIDR range of the form x.x.x.x/x.
|
| 36 |
+
|
| 37 |
+
SubnetId:
|
| 38 |
+
Type: AWS::EC2::Subnet::Id
|
| 39 |
+
|
| 40 |
+
Resources:
|
| 41 |
+
EC2Instance:
|
| 42 |
+
CreationPolicy:
|
| 43 |
+
ResourceSignal:
|
| 44 |
+
Count: 1
|
| 45 |
+
Timeout: PT15M
|
| 46 |
+
Type: AWS::EC2::Instance
|
| 47 |
+
Metadata:
|
| 48 |
+
AWS::CloudFormation::Init:
|
| 49 |
+
configSets:
|
| 50 |
+
default:
|
| 51 |
+
- 01_setupCfnHup
|
| 52 |
+
- 02_config-amazon-cloudwatch-agent
|
| 53 |
+
- 03_restart_amazon-cloudwatch-agent
|
| 54 |
+
UpdateEnvironment:
|
| 55 |
+
- 02_config-amazon-cloudwatch-agent
|
| 56 |
+
- 03_restart_amazon-cloudwatch-agent
|
| 57 |
+
|
| 58 |
+
# Definition of json configuration of AmazonCloudWatchAgent, you can change the configuration below.
|
| 59 |
+
02_config-amazon-cloudwatch-agent:
|
| 60 |
+
files:
|
| 61 |
+
/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json:
|
| 62 |
+
content: |
|
| 63 |
+
{
|
| 64 |
+
"metrics": {
|
| 65 |
+
"append_dimensions": {
|
| 66 |
+
"AutoScalingGroupName": "${!aws:AutoScalingGroupName}",
|
| 67 |
+
"ImageId": "${!aws:ImageId}",
|
| 68 |
+
"InstanceId": "${!aws:InstanceId}",
|
| 69 |
+
"InstanceType": "${!aws:InstanceType}"
|
| 70 |
+
},
|
| 71 |
+
"metrics_collected": {
|
| 72 |
+
"mem": {
|
| 73 |
+
"measurement": [
|
| 74 |
+
"mem_used_percent"
|
| 75 |
+
]
|
| 76 |
+
},
|
| 77 |
+
"swap": {
|
| 78 |
+
"measurement": [
|
| 79 |
+
"swap_used_percent"
|
| 80 |
+
]
|
| 81 |
+
}
|
| 82 |
+
}
|
| 83 |
+
}
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
# Invoke amazon-cloudwatch-agent-ctl to restart the AmazonCloudWatchAgent.
|
| 87 |
+
03_restart_amazon-cloudwatch-agent:
|
| 88 |
+
commands:
|
| 89 |
+
01_stop_service:
|
| 90 |
+
command: /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a stop
|
| 91 |
+
02_start_service:
|
| 92 |
+
command: /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json -s
|
| 93 |
+
|
| 94 |
+
# Cfn-hup setting, it is to monitor the change of metadata.
|
| 95 |
+
# When there is change in the contents of json file in the metadata section, cfn-hup will call cfn-init to restart the AmazonCloudWatchAgent.
|
| 96 |
+
01_setupCfnHup:
|
| 97 |
+
files:
|
| 98 |
+
/etc/cfn/cfn-hup.conf:
|
| 99 |
+
content: !Sub |
|
| 100 |
+
[main]
|
| 101 |
+
stack=${AWS::StackId}
|
| 102 |
+
region=${AWS::Region}
|
| 103 |
+
interval=1
|
| 104 |
+
mode: "000400"
|
| 105 |
+
owner: root
|
| 106 |
+
group: root
|
| 107 |
+
/etc/cfn/hooks.d/amazon-cloudwatch-agent-auto-reloader.conf:
|
| 108 |
+
content: !Sub |
|
| 109 |
+
[cfn-auto-reloader-hook]
|
| 110 |
+
triggers=post.update
|
| 111 |
+
path=Resources.EC2Instance.Metadata.AWS::CloudFormation::Init.02_config-amazon-cloudwatch-agent
|
| 112 |
+
action=/opt/aws/bin/cfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets UpdateEnvironment
|
| 113 |
+
runas=root
|
| 114 |
+
mode: "000400"
|
| 115 |
+
owner: root
|
| 116 |
+
group: root
|
| 117 |
+
/lib/systemd/system/cfn-hup.service:
|
| 118 |
+
content: |
|
| 119 |
+
[Unit]
|
| 120 |
+
Description=cfn-hup daemon
|
| 121 |
+
[Service]
|
| 122 |
+
Type=simple
|
| 123 |
+
ExecStart=/opt/aws/bin/cfn-hup
|
| 124 |
+
Restart=always
|
| 125 |
+
[Install]
|
| 126 |
+
WantedBy=multi-user.target
|
| 127 |
+
commands:
|
| 128 |
+
01enable_cfn_hup:
|
| 129 |
+
command: systemctl enable cfn-hup.service
|
| 130 |
+
02start_cfn_hup:
|
| 131 |
+
command: systemctl start cfn-hup.service
|
| 132 |
+
Properties:
|
| 133 |
+
InstanceType: !Ref InstanceType
|
| 134 |
+
IamInstanceProfile: !Ref IAMRole
|
| 135 |
+
KeyName: !Ref KeyName
|
| 136 |
+
ImageId: !Ref InstanceAMI
|
| 137 |
+
SubnetId: !Ref SubnetId
|
| 138 |
+
SecurityGroupIds:
|
| 139 |
+
- !GetAtt InstanceSecurityGroup.GroupId
|
| 140 |
+
UserData: !Base64
|
| 141 |
+
Fn::Sub: |
|
| 142 |
+
#!/bin/bash
|
| 143 |
+
rpm -Uvh https://s3.amazonaws.com/amazoncloudwatch-agent/amazon_linux/amd64/latest/amazon-cloudwatch-agent.rpm
|
| 144 |
+
/opt/aws/bin/cfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets default
|
| 145 |
+
/opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region}
|
| 146 |
+
|
| 147 |
+
InstanceSecurityGroup:
|
| 148 |
+
Type: AWS::EC2::SecurityGroup
|
| 149 |
+
Properties:
|
| 150 |
+
GroupDescription: Enable SSH access via port 22
|
| 151 |
+
SecurityGroupIngress:
|
| 152 |
+
- IpProtocol: tcp
|
| 153 |
+
FromPort: "22"
|
| 154 |
+
ToPort: "22"
|
| 155 |
+
CidrIp: !Ref SSHLocation
|
human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/inline/centos.json
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"AWSTemplateFormatVersion": "2010-09-09",
|
| 3 |
+
"Description": "Template to install CloudWatchAgent on centos. It was validated on centos 7",
|
| 4 |
+
"Parameters": {
|
| 5 |
+
"KeyName": {
|
| 6 |
+
"Description": "Name of an existing EC2 KeyPair to enable SSH access to the instance",
|
| 7 |
+
"Type": "AWS::EC2::KeyPair::KeyName",
|
| 8 |
+
"ConstraintDescription": "must be the name of an existing EC2 KeyPair."
|
| 9 |
+
},
|
| 10 |
+
"InstanceType": {
|
| 11 |
+
"Description": "EC2 instance type",
|
| 12 |
+
"Type": "String",
|
| 13 |
+
"Default": "t3.medium",
|
| 14 |
+
"ConstraintDescription": "must be a valid EC2 instance type."
|
| 15 |
+
},
|
| 16 |
+
"CentOSVersion": {
|
| 17 |
+
"Type": "String",
|
| 18 |
+
"AllowedValues": [
|
| 19 |
+
"CentOS9"
|
| 20 |
+
],
|
| 21 |
+
"Default": "CentOS9",
|
| 22 |
+
"Description": "CentOS version to deploy"
|
| 23 |
+
},
|
| 24 |
+
"IAMRole": {
|
| 25 |
+
"Description": "EC2 attached IAM role",
|
| 26 |
+
"Type": "String",
|
| 27 |
+
"Default": "CloudWatchAgentAdminRole",
|
| 28 |
+
"ConstraintDescription": "must be an existing IAM role which will be attached to EC2 instance."
|
| 29 |
+
},
|
| 30 |
+
"SSHLocation": {
|
| 31 |
+
"Description": "The IP address range that can be used to SSH to the EC2 instances",
|
| 32 |
+
"Type": "String",
|
| 33 |
+
"Default": "0.0.0.0/0",
|
| 34 |
+
"MinLength": "9",
|
| 35 |
+
"MaxLength": "18",
|
| 36 |
+
"AllowedPattern": "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})",
|
| 37 |
+
"ConstraintDescription": "must be a valid IP CIDR range of the form x.x.x.x/x."
|
| 38 |
+
},
|
| 39 |
+
"SubnetId": {
|
| 40 |
+
"Type": "AWS::EC2::Subnet::Id"
|
| 41 |
+
}
|
| 42 |
+
},
|
| 43 |
+
"Mappings": {
|
| 44 |
+
"RegionMap": {
|
| 45 |
+
"us-east-1": {
|
| 46 |
+
"CentOS9": "ami-0705f7887207411ca"
|
| 47 |
+
},
|
| 48 |
+
"us-east-2": {
|
| 49 |
+
"CentOS9": "ami-0fe2c46c1dc3889fa"
|
| 50 |
+
},
|
| 51 |
+
"us-west-1": {
|
| 52 |
+
"CentOS9": "ami-0f4f63d1732fd4ef5"
|
| 53 |
+
},
|
| 54 |
+
"us-west-2": {
|
| 55 |
+
"CentOS9": "ami-00b231246df1d28de"
|
| 56 |
+
},
|
| 57 |
+
"eu-west-1": {
|
| 58 |
+
"CentOS9": "ami-05a7b8270231783b2"
|
| 59 |
+
},
|
| 60 |
+
"eu-west-2": {
|
| 61 |
+
"RHEL9": "ami-0086646e63ce5aaf1"
|
| 62 |
+
},
|
| 63 |
+
"ap-northeast-1": {
|
| 64 |
+
"RHEL9": "ami-0d8ee41b4b6f8343b"
|
| 65 |
+
},
|
| 66 |
+
"ap-northeast-2": {
|
| 67 |
+
"RHEL9": "ami-031e0786d2134adf6"
|
| 68 |
+
},
|
| 69 |
+
"ap-southeast-1": {
|
| 70 |
+
"RHEL9": "ami-0a9082a6b182a840b"
|
| 71 |
+
},
|
| 72 |
+
"ap-southeast-2": {
|
| 73 |
+
"RHEL9": "ami-05ffc8a6cb624035b"
|
| 74 |
+
}
|
| 75 |
+
}
|
| 76 |
+
},
|
| 77 |
+
"Resources": {
|
| 78 |
+
"EC2Instance": {
|
| 79 |
+
"CreationPolicy": {
|
| 80 |
+
"ResourceSignal": {
|
| 81 |
+
"Count": 1,
|
| 82 |
+
"Timeout": "PT15M"
|
| 83 |
+
}
|
| 84 |
+
},
|
| 85 |
+
"Type": "AWS::EC2::Instance",
|
| 86 |
+
"Metadata": {
|
| 87 |
+
"AWS::CloudFormation::Init": {
|
| 88 |
+
"configSets": {
|
| 89 |
+
"default": [
|
| 90 |
+
"01_setupCfnHup",
|
| 91 |
+
"02_config-amazon-cloudwatch-agent",
|
| 92 |
+
"03_restart_amazon-cloudwatch-agent"
|
| 93 |
+
],
|
| 94 |
+
"UpdateEnvironment": [
|
| 95 |
+
"02_config-amazon-cloudwatch-agent",
|
| 96 |
+
"03_restart_amazon-cloudwatch-agent"
|
| 97 |
+
]
|
| 98 |
+
},
|
| 99 |
+
"02_config-amazon-cloudwatch-agent": {
|
| 100 |
+
"files": {
|
| 101 |
+
"/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json": {
|
| 102 |
+
"content": "{\n \"metrics\": {\n \"append_dimensions\": {\n \"AutoScalingGroupName\": \"${!aws:AutoScalingGroupName}\",\n \"ImageId\": \"${!aws:ImageId}\",\n \"InstanceId\": \"${!aws:InstanceId}\",\n \"InstanceType\": \"${!aws:InstanceType}\"\n },\n \"metrics_collected\": {\n \"mem\": {\n \"measurement\": [\n \"mem_used_percent\"\n ]\n },\n \"swap\": {\n \"measurement\": [\n \"swap_used_percent\"\n ]\n }\n }\n }\n}\n"
|
| 103 |
+
}
|
| 104 |
+
}
|
| 105 |
+
},
|
| 106 |
+
"03_restart_amazon-cloudwatch-agent": {
|
| 107 |
+
"commands": {
|
| 108 |
+
"01_stop_service": {
|
| 109 |
+
"command": "/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a stop"
|
| 110 |
+
},
|
| 111 |
+
"02_start_service": {
|
| 112 |
+
"command": "/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json -s"
|
| 113 |
+
}
|
| 114 |
+
}
|
| 115 |
+
},
|
| 116 |
+
"01_setupCfnHup": {
|
| 117 |
+
"files": {
|
| 118 |
+
"/etc/cfn/cfn-hup.conf": {
|
| 119 |
+
"content": {
|
| 120 |
+
"Fn::Sub": "[main]\nstack=${AWS::StackId}\nregion=${AWS::Region}\ninterval=1\n"
|
| 121 |
+
},
|
| 122 |
+
"mode": "000400",
|
| 123 |
+
"owner": "root",
|
| 124 |
+
"group": "root"
|
| 125 |
+
},
|
| 126 |
+
"/etc/cfn/hooks.d/amazon-cloudwatch-agent-auto-reloader.conf": {
|
| 127 |
+
"content": {
|
| 128 |
+
"Fn::Sub": "[cfn-auto-reloader-hook]\ntriggers=post.update\npath=Resources.EC2Instance.Metadata.AWS::CloudFormation::Init.02_config-amazon-cloudwatch-agent\naction=/opt/aws/bin/cfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets UpdateEnvironment\nrunas=root\n"
|
| 129 |
+
},
|
| 130 |
+
"mode": "000400",
|
| 131 |
+
"owner": "root",
|
| 132 |
+
"group": "root"
|
| 133 |
+
},
|
| 134 |
+
"/lib/systemd/system/cfn-hup.service": {
|
| 135 |
+
"content": "[Unit]\nDescription=cfn-hup daemon\n[Service]\nType=simple\nExecStart=/opt/aws/bin/cfn-hup\nRestart=always\n[Install]\nWantedBy=multi-user.target\n"
|
| 136 |
+
}
|
| 137 |
+
},
|
| 138 |
+
"commands": {
|
| 139 |
+
"01enable_cfn_hup": {
|
| 140 |
+
"command": "systemctl enable cfn-hup.service"
|
| 141 |
+
},
|
| 142 |
+
"02start_cfn_hup": {
|
| 143 |
+
"command": "systemctl start cfn-hup.service"
|
| 144 |
+
}
|
| 145 |
+
}
|
| 146 |
+
}
|
| 147 |
+
}
|
| 148 |
+
},
|
| 149 |
+
"Properties": {
|
| 150 |
+
"InstanceType": {
|
| 151 |
+
"Ref": "InstanceType"
|
| 152 |
+
},
|
| 153 |
+
"IamInstanceProfile": {
|
| 154 |
+
"Ref": "IAMRole"
|
| 155 |
+
},
|
| 156 |
+
"KeyName": {
|
| 157 |
+
"Ref": "KeyName"
|
| 158 |
+
},
|
| 159 |
+
"ImageId": {
|
| 160 |
+
"Fn::FindInMap": [
|
| 161 |
+
"RegionMap",
|
| 162 |
+
{
|
| 163 |
+
"Ref": "AWS::Region"
|
| 164 |
+
},
|
| 165 |
+
{
|
| 166 |
+
"Ref": "CentOSVersion"
|
| 167 |
+
}
|
| 168 |
+
]
|
| 169 |
+
},
|
| 170 |
+
"SubnetId": {
|
| 171 |
+
"Ref": "SubnetId"
|
| 172 |
+
},
|
| 173 |
+
"SecurityGroupIds": [
|
| 174 |
+
{
|
| 175 |
+
|
| 176 |
+
"Fn::GetAtt" : [ "InstanceSecurityGroup", "GroupId" ]
|
| 177 |
+
}
|
| 178 |
+
],
|
| 179 |
+
"UserData": {
|
| 180 |
+
"Fn::Base64": {
|
| 181 |
+
"Fn::Sub": "#!/bin/bash\nrpm -Uvh https://s3.amazonaws.com/amazoncloudwatch-agent/centos/amd64/latest/amazon-cloudwatch-agent.rpm\nyum update -y\nyum install python3 -y\ncurl -O https://bootstrap.pypa.io/get-pip.py\n# Install pip using python3\npython3 get-pip.py\nexport PATH=$PATH:/usr/local/bin\npip3 install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz\ncfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets default\ncfn-signal -e $? --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region}\n"
|
| 182 |
+
}
|
| 183 |
+
}
|
| 184 |
+
}
|
| 185 |
+
},
|
| 186 |
+
"InstanceSecurityGroup": {
|
| 187 |
+
"Type": "AWS::EC2::SecurityGroup",
|
| 188 |
+
"Properties": {
|
| 189 |
+
"GroupDescription": "Enable SSH access via port 22",
|
| 190 |
+
"SecurityGroupIngress": [
|
| 191 |
+
{
|
| 192 |
+
"IpProtocol": "tcp",
|
| 193 |
+
"FromPort": "22",
|
| 194 |
+
"ToPort": "22",
|
| 195 |
+
"CidrIp": {
|
| 196 |
+
"Ref": "SSHLocation"
|
| 197 |
+
}
|
| 198 |
+
}
|
| 199 |
+
]
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
AWSTemplateFormatVersion: "2010-09-09"
|
| 2 |
+
|
| 3 |
+
Description: Template to install CloudWatchAgent on centos. It was validated on centos 7
|
| 4 |
+
|
| 5 |
+
Parameters:
|
| 6 |
+
KeyName:
|
| 7 |
+
Description: Name of an existing EC2 KeyPair to enable SSH access to the instance
|
| 8 |
+
Type: AWS::EC2::KeyPair::KeyName
|
| 9 |
+
ConstraintDescription: must be the name of an existing EC2 KeyPair.
|
| 10 |
+
|
| 11 |
+
InstanceType:
|
| 12 |
+
Description: EC2 instance type
|
| 13 |
+
Type: String
|
| 14 |
+
Default: t3.medium
|
| 15 |
+
ConstraintDescription: must be a valid EC2 instance type.
|
| 16 |
+
|
| 17 |
+
CentOSVersion:
|
| 18 |
+
Type: String
|
| 19 |
+
AllowedValues:
|
| 20 |
+
- CentOS9
|
| 21 |
+
Default: CentOS9
|
| 22 |
+
Description: CentOS version to deploy
|
| 23 |
+
|
| 24 |
+
IAMRole:
|
| 25 |
+
Description: EC2 attached IAM role
|
| 26 |
+
Type: String
|
| 27 |
+
Default: CloudWatchAgentAdminRole
|
| 28 |
+
ConstraintDescription: must be an existing IAM role which will be attached to EC2 instance.
|
| 29 |
+
|
| 30 |
+
SSHLocation:
|
| 31 |
+
Description: The IP address range that can be used to SSH to the EC2 instances
|
| 32 |
+
Type: String
|
| 33 |
+
Default: 0.0.0.0/0
|
| 34 |
+
MinLength: "9"
|
| 35 |
+
MaxLength: "18"
|
| 36 |
+
AllowedPattern: (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/(\d{1,2})
|
| 37 |
+
ConstraintDescription: must be a valid IP CIDR range of the form x.x.x.x/x.
|
| 38 |
+
|
| 39 |
+
SubnetId:
|
| 40 |
+
Type: AWS::EC2::Subnet::Id
|
| 41 |
+
|
| 42 |
+
Mappings:
|
| 43 |
+
RegionMap:
|
| 44 |
+
us-east-1:
|
| 45 |
+
CentOS9: ami-0705f7887207411ca
|
| 46 |
+
us-east-2:
|
| 47 |
+
CentOS9: ami-0fe2c46c1dc3889fa
|
| 48 |
+
us-west-1:
|
| 49 |
+
CentOS9: ami-0f4f63d1732fd4ef5
|
| 50 |
+
us-west-2:
|
| 51 |
+
CentOS9: ami-00b231246df1d28de
|
| 52 |
+
eu-west-1:
|
| 53 |
+
CentOS9: ami-05a7b8270231783b2
|
| 54 |
+
eu-west-2:
|
| 55 |
+
CentOS9: ami-0086646e63ce5aaf1
|
| 56 |
+
ap-northeast-1:
|
| 57 |
+
CentOS9: ami-0d8ee41b4b6f8343b
|
| 58 |
+
ap-northeast-2:
|
| 59 |
+
CentOS9: ami-031e0786d2134adf6
|
| 60 |
+
ap-southeast-1:
|
| 61 |
+
CentOS9: ami-0a9082a6b182a840b
|
| 62 |
+
ap-southeast-2:
|
| 63 |
+
CentOS9: ami-05ffc8a6cb624035b
|
| 64 |
+
|
| 65 |
+
Resources:
|
| 66 |
+
EC2Instance:
|
| 67 |
+
CreationPolicy:
|
| 68 |
+
ResourceSignal:
|
| 69 |
+
Count: 1
|
| 70 |
+
Timeout: PT15M
|
| 71 |
+
Type: AWS::EC2::Instance
|
| 72 |
+
Metadata:
|
| 73 |
+
AWS::CloudFormation::Init:
|
| 74 |
+
configSets:
|
| 75 |
+
default:
|
| 76 |
+
- 01_setupCfnHup
|
| 77 |
+
- 02_config-amazon-cloudwatch-agent
|
| 78 |
+
- 03_restart_amazon-cloudwatch-agent
|
| 79 |
+
UpdateEnvironment:
|
| 80 |
+
- 02_config-amazon-cloudwatch-agent
|
| 81 |
+
- 03_restart_amazon-cloudwatch-agent
|
| 82 |
+
|
| 83 |
+
# Definition of json configuration of AmazonCloudWatchAgent, you can change the configuration below.
|
| 84 |
+
02_config-amazon-cloudwatch-agent:
|
| 85 |
+
files:
|
| 86 |
+
/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json:
|
| 87 |
+
content: |
|
| 88 |
+
{
|
| 89 |
+
"metrics": {
|
| 90 |
+
"append_dimensions": {
|
| 91 |
+
"AutoScalingGroupName": "${!aws:AutoScalingGroupName}",
|
| 92 |
+
"ImageId": "${!aws:ImageId}",
|
| 93 |
+
"InstanceId": "${!aws:InstanceId}",
|
| 94 |
+
"InstanceType": "${!aws:InstanceType}"
|
| 95 |
+
},
|
| 96 |
+
"metrics_collected": {
|
| 97 |
+
"mem": {
|
| 98 |
+
"measurement": [
|
| 99 |
+
"mem_used_percent"
|
| 100 |
+
]
|
| 101 |
+
},
|
| 102 |
+
"swap": {
|
| 103 |
+
"measurement": [
|
| 104 |
+
"swap_used_percent"
|
| 105 |
+
]
|
| 106 |
+
}
|
| 107 |
+
}
|
| 108 |
+
}
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
# Invoke amazon-cloudwatch-agent-ctl to restart the AmazonCloudWatchAgent.
|
| 112 |
+
03_restart_amazon-cloudwatch-agent:
|
| 113 |
+
commands:
|
| 114 |
+
01_stop_service:
|
| 115 |
+
command: /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a stop
|
| 116 |
+
02_start_service:
|
| 117 |
+
command: /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json -s
|
| 118 |
+
|
| 119 |
+
# Cfn-hup setting, it is to monitor the change of metadata.
|
| 120 |
+
# When there is change in the contents of json file in the metadata section, cfn-hup will call cfn-init to restart the AmazonCloudWatchAgent.
|
| 121 |
+
01_setupCfnHup:
|
| 122 |
+
files:
|
| 123 |
+
/etc/cfn/cfn-hup.conf:
|
| 124 |
+
content: !Sub |
|
| 125 |
+
[main]
|
| 126 |
+
stack=${AWS::StackId}
|
| 127 |
+
region=${AWS::Region}
|
| 128 |
+
interval=1
|
| 129 |
+
mode: "000400"
|
| 130 |
+
owner: root
|
| 131 |
+
group: root
|
| 132 |
+
/etc/cfn/hooks.d/amazon-cloudwatch-agent-auto-reloader.conf:
|
| 133 |
+
content: !Sub |
|
| 134 |
+
[cfn-auto-reloader-hook]
|
| 135 |
+
triggers=post.update
|
| 136 |
+
path=Resources.EC2Instance.Metadata.AWS::CloudFormation::Init.02_config-amazon-cloudwatch-agent
|
| 137 |
+
action=/opt/aws/bin/cfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets UpdateEnvironment
|
| 138 |
+
runas=root
|
| 139 |
+
mode: "000400"
|
| 140 |
+
owner: root
|
| 141 |
+
group: root
|
| 142 |
+
/lib/systemd/system/cfn-hup.service:
|
| 143 |
+
content: |
|
| 144 |
+
[Unit]
|
| 145 |
+
Description=cfn-hup daemon
|
| 146 |
+
[Service]
|
| 147 |
+
Type=simple
|
| 148 |
+
ExecStart=/opt/aws/bin/cfn-hup
|
| 149 |
+
Restart=always
|
| 150 |
+
[Install]
|
| 151 |
+
WantedBy=multi-user.target
|
| 152 |
+
commands:
|
| 153 |
+
01enable_cfn_hup:
|
| 154 |
+
command: systemctl enable cfn-hup.service
|
| 155 |
+
02start_cfn_hup:
|
| 156 |
+
command: systemctl start cfn-hup.service
|
| 157 |
+
Properties:
|
| 158 |
+
InstanceType: !Ref InstanceType
|
| 159 |
+
IamInstanceProfile: !Ref IAMRole
|
| 160 |
+
KeyName: !Ref KeyName
|
| 161 |
+
ImageId: !FindInMap
|
| 162 |
+
- RegionMap
|
| 163 |
+
- !Ref 'AWS::Region'
|
| 164 |
+
- !Ref CentOSVersion
|
| 165 |
+
SubnetId: !Ref SubnetId
|
| 166 |
+
SecurityGroupIds:
|
| 167 |
+
- !GetAtt InstanceSecurityGroup.GroupId
|
| 168 |
+
UserData: !Base64
|
| 169 |
+
Fn::Sub: |
|
| 170 |
+
#!/bin/bash
|
| 171 |
+
rpm -Uvh https://s3.amazonaws.com/amazoncloudwatch-agent/centos/amd64/latest/amazon-cloudwatch-agent.rpm
|
| 172 |
+
yum update -y
|
| 173 |
+
yum install python3 -y
|
| 174 |
+
curl -O https://bootstrap.pypa.io/get-pip.py
|
| 175 |
+
# Install pip using python3
|
| 176 |
+
python3 get-pip.py
|
| 177 |
+
export PATH=$PATH:/usr/local/bin
|
| 178 |
+
pip3 install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz
|
| 179 |
+
cfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets default
|
| 180 |
+
cfn-signal -e $? --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region}
|
| 181 |
+
|
| 182 |
+
InstanceSecurityGroup:
|
| 183 |
+
Type: AWS::EC2::SecurityGroup
|
| 184 |
+
Properties:
|
| 185 |
+
GroupDescription: Enable SSH access via port 22
|
| 186 |
+
SecurityGroupIngress:
|
| 187 |
+
- IpProtocol: tcp
|
| 188 |
+
FromPort: "22"
|
| 189 |
+
ToPort: "22"
|
| 190 |
+
CidrIp: !Ref SSHLocation
|
human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/inline/debian.json
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"AWSTemplateFormatVersion": "2010-09-09",
|
| 3 |
+
"Description": "Template to install CloudWatchAgent on debian. It was validated on debian 12.0",
|
| 4 |
+
"Parameters": {
|
| 5 |
+
"KeyName": {
|
| 6 |
+
"Description": "Name of an existing EC2 KeyPair to enable SSH access to the instance",
|
| 7 |
+
"Type": "AWS::EC2::KeyPair::KeyName",
|
| 8 |
+
"ConstraintDescription": "must be the name of an existing EC2 KeyPair."
|
| 9 |
+
},
|
| 10 |
+
"InstanceType": {
|
| 11 |
+
"Description": "EC2 instance type",
|
| 12 |
+
"Type": "String",
|
| 13 |
+
"Default": "t3.medium",
|
| 14 |
+
"ConstraintDescription": "must be a valid EC2 instance type."
|
| 15 |
+
},
|
| 16 |
+
"InstanceAMI": {
|
| 17 |
+
"Description": "Managed AMI ID for EC2 Instance",
|
| 18 |
+
"Type": "AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>",
|
| 19 |
+
"Default": "/aws/service/debian/release/10/latest/amd64"
|
| 20 |
+
},
|
| 21 |
+
"IAMRole": {
|
| 22 |
+
"Description": "EC2 attached IAM role",
|
| 23 |
+
"Type": "String",
|
| 24 |
+
"Default": "CloudWatchAgentAdminRole",
|
| 25 |
+
"ConstraintDescription": "must be an existing IAM role which will be attached to EC2 instance."
|
| 26 |
+
},
|
| 27 |
+
"SSHLocation": {
|
| 28 |
+
"Description": "The IP address range that can be used to SSH to the EC2 instances",
|
| 29 |
+
"Type": "String",
|
| 30 |
+
"Default": "0.0.0.0/0",
|
| 31 |
+
"MinLength": "9",
|
| 32 |
+
"MaxLength": "18",
|
| 33 |
+
"AllowedPattern": "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})",
|
| 34 |
+
"ConstraintDescription": "must be a valid IP CIDR range of the form x.x.x.x/x."
|
| 35 |
+
},
|
| 36 |
+
"SubnetId": {
|
| 37 |
+
"Type": "AWS::EC2::Subnet::Id"
|
| 38 |
+
}
|
| 39 |
+
},
|
| 40 |
+
"Resources": {
|
| 41 |
+
"EC2Instance": {
|
| 42 |
+
"CreationPolicy": {
|
| 43 |
+
"ResourceSignal": {
|
| 44 |
+
"Count": 1,
|
| 45 |
+
"Timeout": "PT15M"
|
| 46 |
+
}
|
| 47 |
+
},
|
| 48 |
+
"Type": "AWS::EC2::Instance",
|
| 49 |
+
"Metadata": {
|
| 50 |
+
"AWS::CloudFormation::Init": {
|
| 51 |
+
"configSets": {
|
| 52 |
+
"default": [
|
| 53 |
+
"01_setupCfnHup",
|
| 54 |
+
"02_config-amazon-cloudwatch-agent",
|
| 55 |
+
"03_restart_amazon-cloudwatch-agent"
|
| 56 |
+
],
|
| 57 |
+
"UpdateEnvironment": [
|
| 58 |
+
"02_config-amazon-cloudwatch-agent",
|
| 59 |
+
"03_restart_amazon-cloudwatch-agent"
|
| 60 |
+
]
|
| 61 |
+
},
|
| 62 |
+
"02_config-amazon-cloudwatch-agent": {
|
| 63 |
+
"files": {
|
| 64 |
+
"/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json": {
|
| 65 |
+
"content": "{\n \"metrics\": {\n \"append_dimensions\": {\n \"AutoScalingGroupName\": \"${!aws:AutoScalingGroupName}\",\n \"ImageId\": \"${!aws:ImageId}\",\n \"InstanceId\": \"${!aws:InstanceId}\",\n \"InstanceType\": \"${!aws:InstanceType}\"\n },\n \"metrics_collected\": {\n \"mem\": {\n \"measurement\": [\n \"mem_used_percent\"\n ]\n },\n \"swap\": {\n \"measurement\": [\n \"swap_used_percent\"\n ]\n }\n }\n }\n}\n"
|
| 66 |
+
}
|
| 67 |
+
}
|
| 68 |
+
},
|
| 69 |
+
"03_restart_amazon-cloudwatch-agent": {
|
| 70 |
+
"commands": {
|
| 71 |
+
"01_stop_service": {
|
| 72 |
+
"command": "/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a stop"
|
| 73 |
+
},
|
| 74 |
+
"02_start_service": {
|
| 75 |
+
"command": "/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json -s"
|
| 76 |
+
}
|
| 77 |
+
}
|
| 78 |
+
},
|
| 79 |
+
"01_setupCfnHup": {
|
| 80 |
+
"files": {
|
| 81 |
+
"/etc/cfn/cfn-hup.conf": {
|
| 82 |
+
"content": {
|
| 83 |
+
"Fn::Sub": "[main]\nstack=${AWS::StackId}\nregion=${AWS::Region}\ninterval=1\n"
|
| 84 |
+
},
|
| 85 |
+
"mode": "000400",
|
| 86 |
+
"owner": "root",
|
| 87 |
+
"group": "root"
|
| 88 |
+
},
|
| 89 |
+
"/etc/cfn/hooks.d/amazon-cloudwatch-agent-auto-reloader.conf": {
|
| 90 |
+
"content": {
|
| 91 |
+
"Fn::Sub": "[cfn-auto-reloader-hook]\ntriggers=post.update\npath=Resources.EC2Instance.Metadata.AWS::CloudFormation::Init.02_config-amazon-cloudwatch-agent\naction=/opt/aws/bin/cfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets UpdateEnvironment\nrunas=root\n"
|
| 92 |
+
},
|
| 93 |
+
"mode": "000400",
|
| 94 |
+
"owner": "root",
|
| 95 |
+
"group": "root"
|
| 96 |
+
},
|
| 97 |
+
"/lib/systemd/system/cfn-hup.service": {
|
| 98 |
+
"content": "[Unit]\nDescription=cfn-hup daemon\n[Service]\nType=simple\nExecStart=/opt/aws/bin/cfn-hup\nRestart=always\n[Install]\nWantedBy=multi-user.target\n"
|
| 99 |
+
}
|
| 100 |
+
},
|
| 101 |
+
"commands": {
|
| 102 |
+
"01enable_cfn_hup": {
|
| 103 |
+
"command": "systemctl enable cfn-hup.service"
|
| 104 |
+
},
|
| 105 |
+
"02start_cfn_hup": {
|
| 106 |
+
"command": "systemctl start cfn-hup.service"
|
| 107 |
+
}
|
| 108 |
+
}
|
| 109 |
+
}
|
| 110 |
+
}
|
| 111 |
+
},
|
| 112 |
+
"Properties": {
|
| 113 |
+
"InstanceType": {
|
| 114 |
+
"Ref": "InstanceType"
|
| 115 |
+
},
|
| 116 |
+
"IamInstanceProfile": {
|
| 117 |
+
"Ref": "IAMRole"
|
| 118 |
+
},
|
| 119 |
+
"KeyName": {
|
| 120 |
+
"Ref": "KeyName"
|
| 121 |
+
},
|
| 122 |
+
"ImageId": {
|
| 123 |
+
"Ref": "InstanceAMI"
|
| 124 |
+
},
|
| 125 |
+
"SubnetId": {
|
| 126 |
+
"Ref": "SubnetId"
|
| 127 |
+
},
|
| 128 |
+
"SecurityGroupIds": [
|
| 129 |
+
{
|
| 130 |
+
|
| 131 |
+
"Fn::GetAtt" : [ "InstanceSecurityGroup", "GroupId" ]
|
| 132 |
+
}
|
| 133 |
+
],
|
| 134 |
+
"UserData": {
|
| 135 |
+
"Fn::Base64": {
|
| 136 |
+
"Fn::Sub": "#!/bin/bash\nwget https://s3.amazonaws.com/amazoncloudwatch-agent/debian/amd64/latest/amazon-cloudwatch-agent.deb -O /tmp/amazon-cloudwatch-agent.deb\nsudo dpkg -i /tmp/amazon-cloudwatch-agent.deb\nwget https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz -O /tmp/aws-cfn-bootstrap-py3-latest.tar.gz\nsudo apt-get update -y\nsudo apt-get install -y python3-pip python3-venv\n\n# Create and activate a virtual environment\npython3 -m venv /opt/aws/virtualenv\nsource /opt/aws/virtualenv/bin/activate\n\n# Install the bootstrap package\npip install /tmp/aws-cfn-bootstrap-py3-latest.tar.gz\n\n# Create necessary symlinks\nsudo mkdir -p /opt/aws/bin\nsudo ln -s /opt/aws/virtualenv/bin/cfn-* /opt/aws/bin/\n\n# Run cfn-init\n/opt/aws/bin/cfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets default\n/opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region}\n"
|
| 137 |
+
}
|
| 138 |
+
}
|
| 139 |
+
}
|
| 140 |
+
},
|
| 141 |
+
"InstanceSecurityGroup": {
|
| 142 |
+
"Type": "AWS::EC2::SecurityGroup",
|
| 143 |
+
"Properties": {
|
| 144 |
+
"GroupDescription": "Enable SSH access via port 22",
|
| 145 |
+
"SecurityGroupIngress": [
|
| 146 |
+
{
|
| 147 |
+
"IpProtocol": "tcp",
|
| 148 |
+
"FromPort": "22",
|
| 149 |
+
"ToPort": "22",
|
| 150 |
+
"CidrIp": {
|
| 151 |
+
"Ref": "SSHLocation"
|
| 152 |
+
}
|
| 153 |
+
}
|
| 154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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
AWSTemplateFormatVersion: "2010-09-09"
|
| 2 |
+
|
| 3 |
+
Description: Template to install CloudWatchAgent on debian. It was validated on debian 12.0
|
| 4 |
+
|
| 5 |
+
Parameters:
|
| 6 |
+
KeyName:
|
| 7 |
+
Description: Name of an existing EC2 KeyPair to enable SSH access to the instance
|
| 8 |
+
Type: AWS::EC2::KeyPair::KeyName
|
| 9 |
+
ConstraintDescription: must be the name of an existing EC2 KeyPair.
|
| 10 |
+
|
| 11 |
+
InstanceType:
|
| 12 |
+
Description: EC2 instance type
|
| 13 |
+
Type: String
|
| 14 |
+
Default: t3.medium
|
| 15 |
+
ConstraintDescription: must be a valid EC2 instance type.
|
| 16 |
+
|
| 17 |
+
InstanceAMI:
|
| 18 |
+
Description: Managed AMI ID for EC2 Instance
|
| 19 |
+
Type: AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>
|
| 20 |
+
Default: /aws/service/debian/release/10/latest/amd64
|
| 21 |
+
|
| 22 |
+
IAMRole:
|
| 23 |
+
Description: EC2 attached IAM role
|
| 24 |
+
Type: String
|
| 25 |
+
Default: CloudWatchAgentAdminRole
|
| 26 |
+
ConstraintDescription: must be an existing IAM role which will be attached to EC2 instance.
|
| 27 |
+
|
| 28 |
+
SSHLocation:
|
| 29 |
+
Description: The IP address range that can be used to SSH to the EC2 instances
|
| 30 |
+
Type: String
|
| 31 |
+
Default: 0.0.0.0/0
|
| 32 |
+
MinLength: "9"
|
| 33 |
+
MaxLength: "18"
|
| 34 |
+
AllowedPattern: (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/(\d{1,2})
|
| 35 |
+
ConstraintDescription: must be a valid IP CIDR range of the form x.x.x.x/x.
|
| 36 |
+
|
| 37 |
+
SubnetId:
|
| 38 |
+
Type: AWS::EC2::Subnet::Id
|
| 39 |
+
|
| 40 |
+
Resources:
|
| 41 |
+
EC2Instance:
|
| 42 |
+
CreationPolicy:
|
| 43 |
+
ResourceSignal:
|
| 44 |
+
Count: 1
|
| 45 |
+
Timeout: PT15M
|
| 46 |
+
Type: AWS::EC2::Instance
|
| 47 |
+
Metadata:
|
| 48 |
+
AWS::CloudFormation::Init:
|
| 49 |
+
configSets:
|
| 50 |
+
default:
|
| 51 |
+
- 01_setupCfnHup
|
| 52 |
+
- 02_config-amazon-cloudwatch-agent
|
| 53 |
+
- 03_restart_amazon-cloudwatch-agent
|
| 54 |
+
UpdateEnvironment:
|
| 55 |
+
- 02_config-amazon-cloudwatch-agent
|
| 56 |
+
- 03_restart_amazon-cloudwatch-agent
|
| 57 |
+
|
| 58 |
+
# Definition of json configuration of AmazonCloudWatchAgent, you can change the configuration below.
|
| 59 |
+
02_config-amazon-cloudwatch-agent:
|
| 60 |
+
files:
|
| 61 |
+
/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json:
|
| 62 |
+
content: |
|
| 63 |
+
{
|
| 64 |
+
"metrics": {
|
| 65 |
+
"append_dimensions": {
|
| 66 |
+
"AutoScalingGroupName": "${!aws:AutoScalingGroupName}",
|
| 67 |
+
"ImageId": "${!aws:ImageId}",
|
| 68 |
+
"InstanceId": "${!aws:InstanceId}",
|
| 69 |
+
"InstanceType": "${!aws:InstanceType}"
|
| 70 |
+
},
|
| 71 |
+
"metrics_collected": {
|
| 72 |
+
"mem": {
|
| 73 |
+
"measurement": [
|
| 74 |
+
"mem_used_percent"
|
| 75 |
+
]
|
| 76 |
+
},
|
| 77 |
+
"swap": {
|
| 78 |
+
"measurement": [
|
| 79 |
+
"swap_used_percent"
|
| 80 |
+
]
|
| 81 |
+
}
|
| 82 |
+
}
|
| 83 |
+
}
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
# Invoke amazon-cloudwatch-agent-ctl to restart the AmazonCloudWatchAgent.
|
| 87 |
+
03_restart_amazon-cloudwatch-agent:
|
| 88 |
+
commands:
|
| 89 |
+
01_stop_service:
|
| 90 |
+
command: /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a stop
|
| 91 |
+
02_start_service:
|
| 92 |
+
command: /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json -s
|
| 93 |
+
|
| 94 |
+
# Cfn-hup setting, it is to monitor the change of metadata.
|
| 95 |
+
# When there is change in the contents of json file in the metadata section, cfn-hup will call cfn-init to restart the AmazonCloudWatchAgent.
|
| 96 |
+
01_setupCfnHup:
|
| 97 |
+
files:
|
| 98 |
+
/etc/cfn/cfn-hup.conf:
|
| 99 |
+
content: !Sub |
|
| 100 |
+
[main]
|
| 101 |
+
stack=${AWS::StackId}
|
| 102 |
+
region=${AWS::Region}
|
| 103 |
+
interval=1
|
| 104 |
+
mode: "000400"
|
| 105 |
+
owner: root
|
| 106 |
+
group: root
|
| 107 |
+
/etc/cfn/hooks.d/amazon-cloudwatch-agent-auto-reloader.conf:
|
| 108 |
+
content: !Sub |
|
| 109 |
+
[cfn-auto-reloader-hook]
|
| 110 |
+
triggers=post.update
|
| 111 |
+
path=Resources.EC2Instance.Metadata.AWS::CloudFormation::Init.02_config-amazon-cloudwatch-agent
|
| 112 |
+
action=/opt/aws/bin/cfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets UpdateEnvironment
|
| 113 |
+
runas=root
|
| 114 |
+
mode: "000400"
|
| 115 |
+
owner: root
|
| 116 |
+
group: root
|
| 117 |
+
/lib/systemd/system/cfn-hup.service:
|
| 118 |
+
content: |
|
| 119 |
+
[Unit]
|
| 120 |
+
Description=cfn-hup daemon
|
| 121 |
+
[Service]
|
| 122 |
+
Type=simple
|
| 123 |
+
ExecStart=/opt/aws/bin/cfn-hup
|
| 124 |
+
Restart=always
|
| 125 |
+
[Install]
|
| 126 |
+
WantedBy=multi-user.target
|
| 127 |
+
commands:
|
| 128 |
+
01enable_cfn_hup:
|
| 129 |
+
command: systemctl enable cfn-hup.service
|
| 130 |
+
02start_cfn_hup:
|
| 131 |
+
command: systemctl start cfn-hup.service
|
| 132 |
+
Properties:
|
| 133 |
+
InstanceType: !Ref InstanceType
|
| 134 |
+
IamInstanceProfile: !Ref IAMRole
|
| 135 |
+
KeyName: !Ref KeyName
|
| 136 |
+
ImageId: !Ref InstanceAMI
|
| 137 |
+
SubnetId: !Ref SubnetId
|
| 138 |
+
SecurityGroupIds:
|
| 139 |
+
- !GetAtt InstanceSecurityGroup.GroupId
|
| 140 |
+
UserData: !Base64
|
| 141 |
+
Fn::Sub: |
|
| 142 |
+
#!/bin/bash
|
| 143 |
+
wget https://s3.amazonaws.com/amazoncloudwatch-agent/debian/amd64/latest/amazon-cloudwatch-agent.deb -O /tmp/amazon-cloudwatch-agent.deb
|
| 144 |
+
sudo dpkg -i /tmp/amazon-cloudwatch-agent.deb
|
| 145 |
+
wget https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz -O /tmp/aws-cfn-bootstrap-py3-latest.tar.gz
|
| 146 |
+
sudo apt-get update -y
|
| 147 |
+
sudo apt-get install -y python3-pip python3-venv
|
| 148 |
+
|
| 149 |
+
# Create and activate a virtual environment
|
| 150 |
+
python3 -m venv /opt/aws/virtualenv
|
| 151 |
+
source /opt/aws/virtualenv/bin/activate
|
| 152 |
+
|
| 153 |
+
# Install the bootstrap package
|
| 154 |
+
pip install /tmp/aws-cfn-bootstrap-py3-latest.tar.gz
|
| 155 |
+
|
| 156 |
+
# Create necessary symlinks
|
| 157 |
+
sudo mkdir -p /opt/aws/bin
|
| 158 |
+
sudo ln -s /opt/aws/virtualenv/bin/cfn-* /opt/aws/bin/
|
| 159 |
+
|
| 160 |
+
# Run cfn-init
|
| 161 |
+
/opt/aws/bin/cfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets default
|
| 162 |
+
/opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region}
|
| 163 |
+
|
| 164 |
+
InstanceSecurityGroup:
|
| 165 |
+
Type: AWS::EC2::SecurityGroup
|
| 166 |
+
Properties:
|
| 167 |
+
GroupDescription: Enable SSH access via port 22
|
| 168 |
+
SecurityGroupIngress:
|
| 169 |
+
- IpProtocol: tcp
|
| 170 |
+
FromPort: "22"
|
| 171 |
+
ToPort: "22"
|
| 172 |
+
CidrIp: !Ref SSHLocation
|
human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/inline/redhat.json
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"AWSTemplateFormatVersion": "2010-09-09",
|
| 3 |
+
"Description": "Template to install CloudWatchAgent on redhat. It was validated on redhat 7.5",
|
| 4 |
+
"Parameters": {
|
| 5 |
+
"KeyName": {
|
| 6 |
+
"Description": "Name of an existing EC2 KeyPair to enable SSH access to the instance",
|
| 7 |
+
"Type": "AWS::EC2::KeyPair::KeyName",
|
| 8 |
+
"ConstraintDescription": "must be the name of an existing EC2 KeyPair."
|
| 9 |
+
},
|
| 10 |
+
"InstanceType": {
|
| 11 |
+
"Description": "EC2 instance type",
|
| 12 |
+
"Type": "String",
|
| 13 |
+
"Default": "t3.medium",
|
| 14 |
+
"ConstraintDescription": "must be a valid EC2 instance type."
|
| 15 |
+
},
|
| 16 |
+
"RHELVersion": {
|
| 17 |
+
"Type": "String",
|
| 18 |
+
"AllowedValues": [
|
| 19 |
+
"RHEL9"
|
| 20 |
+
],
|
| 21 |
+
"Default": "RHEL9",
|
| 22 |
+
"Description": "RHEL version to deploy"
|
| 23 |
+
},
|
| 24 |
+
"IAMRole": {
|
| 25 |
+
"Description": "EC2 attached IAM role",
|
| 26 |
+
"Type": "String",
|
| 27 |
+
"Default": "CloudWatchAgentAdminRole",
|
| 28 |
+
"ConstraintDescription": "must be an existing IAM role which will be attached to EC2 instance."
|
| 29 |
+
},
|
| 30 |
+
"SSHLocation": {
|
| 31 |
+
"Description": "The IP address range that can be used to SSH to the EC2 instances",
|
| 32 |
+
"Type": "String",
|
| 33 |
+
"Default": "0.0.0.0/0",
|
| 34 |
+
"MinLength": "9",
|
| 35 |
+
"MaxLength": "18",
|
| 36 |
+
"AllowedPattern": "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})",
|
| 37 |
+
"ConstraintDescription": "must be a valid IP CIDR range of the form x.x.x.x/x."
|
| 38 |
+
},
|
| 39 |
+
"SubnetId": {
|
| 40 |
+
"Type": "AWS::EC2::Subnet::Id"
|
| 41 |
+
}
|
| 42 |
+
},
|
| 43 |
+
|
| 44 |
+
"Mappings": {
|
| 45 |
+
"RegionMap": {
|
| 46 |
+
"us-east-1": {
|
| 47 |
+
"RHEL9": "ami-0fb13bb53494158e9"
|
| 48 |
+
},
|
| 49 |
+
"us-east-2": {
|
| 50 |
+
"RHEL9": "ami-0aeea2f24f6d3ba32"
|
| 51 |
+
},
|
| 52 |
+
"us-west-1": {
|
| 53 |
+
"RHEL9": "ami-068c2af1200ef7356"
|
| 54 |
+
},
|
| 55 |
+
"us-west-2": {
|
| 56 |
+
"RHEL9": "ami-0367f2b5c3d1ef960"
|
| 57 |
+
},
|
| 58 |
+
"eu-west-1": {
|
| 59 |
+
"RHEL9": "ami-0f0f1c02e5e4d9d9f"
|
| 60 |
+
},
|
| 61 |
+
"eu-west-2": {
|
| 62 |
+
"RHEL9": "ami-02b1e3a99e36afd1a"
|
| 63 |
+
},
|
| 64 |
+
"ap-northeast-1": {
|
| 65 |
+
"RHEL9": "ami-0eade93757ef7bb6c"
|
| 66 |
+
},
|
| 67 |
+
"ap-northeast-2": {
|
| 68 |
+
"RHEL9": "ami-097698b6cd8164ea2"
|
| 69 |
+
},
|
| 70 |
+
"ap-southeast-1": {
|
| 71 |
+
"RHEL9": "ami-0b9521fddc9871128"
|
| 72 |
+
},
|
| 73 |
+
"ap-southeast-2": {
|
| 74 |
+
"RHEL9": "ami-0eea634029e7b983c"
|
| 75 |
+
}
|
| 76 |
+
}
|
| 77 |
+
},
|
| 78 |
+
|
| 79 |
+
"Resources": {
|
| 80 |
+
"EC2Instance": {
|
| 81 |
+
"CreationPolicy": {
|
| 82 |
+
"ResourceSignal": {
|
| 83 |
+
"Count": 1,
|
| 84 |
+
"Timeout": "PT15M"
|
| 85 |
+
}
|
| 86 |
+
},
|
| 87 |
+
"Type": "AWS::EC2::Instance",
|
| 88 |
+
"Metadata": {
|
| 89 |
+
"AWS::CloudFormation::Init": {
|
| 90 |
+
"configSets": {
|
| 91 |
+
"default": [
|
| 92 |
+
"01_setupCfnHup",
|
| 93 |
+
"02_config-amazon-cloudwatch-agent",
|
| 94 |
+
"03_restart_amazon-cloudwatch-agent"
|
| 95 |
+
],
|
| 96 |
+
"UpdateEnvironment": [
|
| 97 |
+
"02_config-amazon-cloudwatch-agent",
|
| 98 |
+
"03_restart_amazon-cloudwatch-agent"
|
| 99 |
+
]
|
| 100 |
+
},
|
| 101 |
+
"02_config-amazon-cloudwatch-agent": {
|
| 102 |
+
"files": {
|
| 103 |
+
"/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json": {
|
| 104 |
+
"content": "{\n \"metrics\": {\n \"append_dimensions\": {\n \"AutoScalingGroupName\": \"${!aws:AutoScalingGroupName}\",\n \"ImageId\": \"${!aws:ImageId}\",\n \"InstanceId\": \"${!aws:InstanceId}\",\n \"InstanceType\": \"${!aws:InstanceType}\"\n },\n \"metrics_collected\": {\n \"mem\": {\n \"measurement\": [\n \"mem_used_percent\"\n ]\n },\n \"swap\": {\n \"measurement\": [\n \"swap_used_percent\"\n ]\n }\n }\n }\n}\n"
|
| 105 |
+
}
|
| 106 |
+
}
|
| 107 |
+
},
|
| 108 |
+
"03_restart_amazon-cloudwatch-agent": {
|
| 109 |
+
"commands": {
|
| 110 |
+
"01_stop_service": {
|
| 111 |
+
"command": "/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a stop"
|
| 112 |
+
},
|
| 113 |
+
"02_start_service": {
|
| 114 |
+
"command": "/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json -s"
|
| 115 |
+
}
|
| 116 |
+
}
|
| 117 |
+
},
|
| 118 |
+
"01_setupCfnHup": {
|
| 119 |
+
"files": {
|
| 120 |
+
"/etc/cfn/cfn-hup.conf": {
|
| 121 |
+
"content": {
|
| 122 |
+
"Fn::Sub": "[main]\nstack=${AWS::StackId}\nregion=${AWS::Region}\ninterval=1\n"
|
| 123 |
+
},
|
| 124 |
+
"mode": "000400",
|
| 125 |
+
"owner": "root",
|
| 126 |
+
"group": "root"
|
| 127 |
+
},
|
| 128 |
+
"/etc/cfn/hooks.d/amazon-cloudwatch-agent-auto-reloader.conf": {
|
| 129 |
+
"content": {
|
| 130 |
+
"Fn::Sub": "[cfn-auto-reloader-hook]\ntriggers=post.update\npath=Resources.EC2Instance.Metadata.AWS::CloudFormation::Init.02_config-amazon-cloudwatch-agent\naction=/opt/aws/bin/cfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets UpdateEnvironment\nrunas=root\n"
|
| 131 |
+
},
|
| 132 |
+
"mode": "000400",
|
| 133 |
+
"owner": "root",
|
| 134 |
+
"group": "root"
|
| 135 |
+
},
|
| 136 |
+
"/lib/systemd/system/cfn-hup.service": {
|
| 137 |
+
"content": "[Unit]\nDescription=cfn-hup daemon\n[Service]\nType=simple\nExecStart=/opt/aws/bin/cfn-hup\nRestart=always\n[Install]\nWantedBy=multi-user.target\n"
|
| 138 |
+
}
|
| 139 |
+
},
|
| 140 |
+
"commands": {
|
| 141 |
+
"01enable_cfn_hup": {
|
| 142 |
+
"command": "systemctl enable cfn-hup.service"
|
| 143 |
+
},
|
| 144 |
+
"02start_cfn_hup": {
|
| 145 |
+
"command": "systemctl start cfn-hup.service"
|
| 146 |
+
}
|
| 147 |
+
}
|
| 148 |
+
}
|
| 149 |
+
}
|
| 150 |
+
},
|
| 151 |
+
"Properties": {
|
| 152 |
+
"InstanceType": {
|
| 153 |
+
"Ref": "InstanceType"
|
| 154 |
+
},
|
| 155 |
+
"IamInstanceProfile": {
|
| 156 |
+
"Ref": "IAMRole"
|
| 157 |
+
},
|
| 158 |
+
"KeyName": {
|
| 159 |
+
"Ref": "KeyName"
|
| 160 |
+
},
|
| 161 |
+
"ImageId": {
|
| 162 |
+
"Fn::FindInMap": [
|
| 163 |
+
"RegionMap",
|
| 164 |
+
{
|
| 165 |
+
"Ref": "AWS::Region"
|
| 166 |
+
},
|
| 167 |
+
{
|
| 168 |
+
"Ref": "RHELVersion"
|
| 169 |
+
}
|
| 170 |
+
]
|
| 171 |
+
},
|
| 172 |
+
"SubnetId": {
|
| 173 |
+
"Ref": "SubnetId"
|
| 174 |
+
},
|
| 175 |
+
"SecurityGroupIds": [
|
| 176 |
+
{
|
| 177 |
+
|
| 178 |
+
"Fn::GetAtt" : [ "InstanceSecurityGroup", "GroupId" ]
|
| 179 |
+
}
|
| 180 |
+
],
|
| 181 |
+
"UserData": {
|
| 182 |
+
"Fn::Base64": {
|
| 183 |
+
"Fn::Sub": "#!/bin/bash\nrpm -Uvh https://s3.amazonaws.com/amazoncloudwatch-agent/redhat/amd64/latest/amazon-cloudwatch-agent.rpm\nyum update -y\nyum install python3 -y\ncurl -O https://bootstrap.pypa.io/get-pip.py\n# Install pip using python3\npython3 get-pip.py\nexport PATH=$PATH:/usr/local/bin\npip3 install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz\ncfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets default\ncfn-signal -e $? --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region}\n"
|
| 184 |
+
}
|
| 185 |
+
}
|
| 186 |
+
}
|
| 187 |
+
},
|
| 188 |
+
"InstanceSecurityGroup": {
|
| 189 |
+
"Type": "AWS::EC2::SecurityGroup",
|
| 190 |
+
"Properties": {
|
| 191 |
+
"GroupDescription": "Enable SSH access via port 22",
|
| 192 |
+
"SecurityGroupIngress": [
|
| 193 |
+
{
|
| 194 |
+
"IpProtocol": "tcp",
|
| 195 |
+
"FromPort": "22",
|
| 196 |
+
"ToPort": "22",
|
| 197 |
+
"CidrIp": {
|
| 198 |
+
"Ref": "SSHLocation"
|
| 199 |
+
}
|
| 200 |
+
}
|
| 201 |
+
]
|
| 202 |
+
}
|
| 203 |
+
}
|
| 204 |
+
}
|
| 205 |
+
}
|
human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/inline/redhat.yaml
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
AWSTemplateFormatVersion: "2010-09-09"
|
| 2 |
+
|
| 3 |
+
Description: Template to install CloudWatchAgent on redhat. It was validated on redhat 7.5
|
| 4 |
+
|
| 5 |
+
Parameters:
|
| 6 |
+
KeyName:
|
| 7 |
+
Description: Name of an existing EC2 KeyPair to enable SSH access to the instance
|
| 8 |
+
Type: AWS::EC2::KeyPair::KeyName
|
| 9 |
+
ConstraintDescription: must be the name of an existing EC2 KeyPair.
|
| 10 |
+
|
| 11 |
+
InstanceType:
|
| 12 |
+
Description: EC2 instance type
|
| 13 |
+
Type: String
|
| 14 |
+
Default: t3.medium
|
| 15 |
+
ConstraintDescription: must be a valid EC2 instance type.
|
| 16 |
+
|
| 17 |
+
RHELVersion:
|
| 18 |
+
Type: String
|
| 19 |
+
AllowedValues:
|
| 20 |
+
- RHEL9
|
| 21 |
+
Default: RHEL9
|
| 22 |
+
Description: RHEL version to deploy
|
| 23 |
+
|
| 24 |
+
IAMRole:
|
| 25 |
+
Description: EC2 attached IAM role
|
| 26 |
+
Type: String
|
| 27 |
+
Default: CloudWatchAgentAdminRole
|
| 28 |
+
ConstraintDescription: must be an existing IAM role which will be attached to EC2 instance.
|
| 29 |
+
|
| 30 |
+
SSHLocation:
|
| 31 |
+
Description: The IP address range that can be used to SSH to the EC2 instances
|
| 32 |
+
Type: String
|
| 33 |
+
Default: 0.0.0.0/0
|
| 34 |
+
MinLength: "9"
|
| 35 |
+
MaxLength: "18"
|
| 36 |
+
AllowedPattern: (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/(\d{1,2})
|
| 37 |
+
ConstraintDescription: must be a valid IP CIDR range of the form x.x.x.x/x.
|
| 38 |
+
|
| 39 |
+
SubnetId:
|
| 40 |
+
Type: AWS::EC2::Subnet::Id
|
| 41 |
+
|
| 42 |
+
Mappings:
|
| 43 |
+
RegionMap:
|
| 44 |
+
us-east-1:
|
| 45 |
+
RHEL9: ami-0fb13bb53494158e9
|
| 46 |
+
us-east-2:
|
| 47 |
+
RHEL9: ami-0aeea2f24f6d3ba32
|
| 48 |
+
us-west-1:
|
| 49 |
+
RHEL9: ami-068c2af1200ef7356
|
| 50 |
+
us-west-2:
|
| 51 |
+
RHEL9: ami-0367f2b5c3d1ef960
|
| 52 |
+
eu-west-1:
|
| 53 |
+
RHEL9: ami-0e28d6c0c65e7f82f
|
| 54 |
+
eu-west-2:
|
| 55 |
+
RHEL9: ami-02b1e3a99e36afd1a
|
| 56 |
+
ap-northeast-1:
|
| 57 |
+
RHEL9: ami-0eade93757ef7bb6c
|
| 58 |
+
ap-northeast-2:
|
| 59 |
+
RHEL9: ami-097698b6cd8164ea2
|
| 60 |
+
ap-southeast-1:
|
| 61 |
+
RHEL9: ami-0b9521fddc9871128
|
| 62 |
+
ap-southeast-2:
|
| 63 |
+
RHEL9: ami-0eea634029e7b983c
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
Resources:
|
| 68 |
+
EC2Instance:
|
| 69 |
+
CreationPolicy:
|
| 70 |
+
ResourceSignal:
|
| 71 |
+
Count: 1
|
| 72 |
+
Timeout: PT15M
|
| 73 |
+
Type: AWS::EC2::Instance
|
| 74 |
+
Metadata:
|
| 75 |
+
AWS::CloudFormation::Init:
|
| 76 |
+
configSets:
|
| 77 |
+
default:
|
| 78 |
+
- 01_setupCfnHup
|
| 79 |
+
- 02_config-amazon-cloudwatch-agent
|
| 80 |
+
- 03_restart_amazon-cloudwatch-agent
|
| 81 |
+
UpdateEnvironment:
|
| 82 |
+
- 02_config-amazon-cloudwatch-agent
|
| 83 |
+
- 03_restart_amazon-cloudwatch-agent
|
| 84 |
+
|
| 85 |
+
# Definition of json configuration of AmazonCloudWatchAgent, you can change the configuration below.
|
| 86 |
+
02_config-amazon-cloudwatch-agent:
|
| 87 |
+
files:
|
| 88 |
+
/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json:
|
| 89 |
+
content: |
|
| 90 |
+
{
|
| 91 |
+
"metrics": {
|
| 92 |
+
"append_dimensions": {
|
| 93 |
+
"AutoScalingGroupName": "${!aws:AutoScalingGroupName}",
|
| 94 |
+
"ImageId": "${!aws:ImageId}",
|
| 95 |
+
"InstanceId": "${!aws:InstanceId}",
|
| 96 |
+
"InstanceType": "${!aws:InstanceType}"
|
| 97 |
+
},
|
| 98 |
+
"metrics_collected": {
|
| 99 |
+
"mem": {
|
| 100 |
+
"measurement": [
|
| 101 |
+
"mem_used_percent"
|
| 102 |
+
]
|
| 103 |
+
},
|
| 104 |
+
"swap": {
|
| 105 |
+
"measurement": [
|
| 106 |
+
"swap_used_percent"
|
| 107 |
+
]
|
| 108 |
+
}
|
| 109 |
+
}
|
| 110 |
+
}
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
# Invoke amazon-cloudwatch-agent-ctl to restart the AmazonCloudWatchAgent.
|
| 114 |
+
03_restart_amazon-cloudwatch-agent:
|
| 115 |
+
commands:
|
| 116 |
+
01_stop_service:
|
| 117 |
+
command: /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a stop
|
| 118 |
+
02_start_service:
|
| 119 |
+
command: /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json -s
|
| 120 |
+
|
| 121 |
+
# Cfn-hup setting, it is to monitor the change of metadata.
|
| 122 |
+
# When there is change in the contents of json file in the metadata section, cfn-hup will call cfn-init to restart the AmazonCloudWatchAgent.
|
| 123 |
+
01_setupCfnHup:
|
| 124 |
+
files:
|
| 125 |
+
/etc/cfn/cfn-hup.conf:
|
| 126 |
+
content: !Sub |
|
| 127 |
+
[main]
|
| 128 |
+
stack=${AWS::StackId}
|
| 129 |
+
region=${AWS::Region}
|
| 130 |
+
interval=1
|
| 131 |
+
mode: "000400"
|
| 132 |
+
owner: root
|
| 133 |
+
group: root
|
| 134 |
+
/etc/cfn/hooks.d/amazon-cloudwatch-agent-auto-reloader.conf:
|
| 135 |
+
content: !Sub |
|
| 136 |
+
[cfn-auto-reloader-hook]
|
| 137 |
+
triggers=post.update
|
| 138 |
+
path=Resources.EC2Instance.Metadata.AWS::CloudFormation::Init.02_config-amazon-cloudwatch-agent
|
| 139 |
+
action=/opt/aws/bin/cfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets UpdateEnvironment
|
| 140 |
+
runas=root
|
| 141 |
+
mode: "000400"
|
| 142 |
+
owner: root
|
| 143 |
+
group: root
|
| 144 |
+
/lib/systemd/system/cfn-hup.service:
|
| 145 |
+
content: |
|
| 146 |
+
[Unit]
|
| 147 |
+
Description=cfn-hup daemon
|
| 148 |
+
[Service]
|
| 149 |
+
Type=simple
|
| 150 |
+
ExecStart=/opt/aws/bin/cfn-hup
|
| 151 |
+
Restart=always
|
| 152 |
+
[Install]
|
| 153 |
+
WantedBy=multi-user.target
|
| 154 |
+
commands:
|
| 155 |
+
01enable_cfn_hup:
|
| 156 |
+
command: systemctl enable cfn-hup.service
|
| 157 |
+
02start_cfn_hup:
|
| 158 |
+
command: systemctl start cfn-hup.service
|
| 159 |
+
Properties:
|
| 160 |
+
InstanceType: !Ref InstanceType
|
| 161 |
+
IamInstanceProfile: !Ref IAMRole
|
| 162 |
+
KeyName: !Ref KeyName
|
| 163 |
+
ImageId: !FindInMap
|
| 164 |
+
- RegionMap
|
| 165 |
+
- !Ref 'AWS::Region'
|
| 166 |
+
- !Ref RHELVersion
|
| 167 |
+
SubnetId: !Ref SubnetId
|
| 168 |
+
SecurityGroupIds:
|
| 169 |
+
- !GetAtt InstanceSecurityGroup.GroupId
|
| 170 |
+
UserData: !Base64
|
| 171 |
+
Fn::Sub: |
|
| 172 |
+
#!/bin/bash
|
| 173 |
+
rpm -Uvh https://s3.amazonaws.com/amazoncloudwatch-agent/redhat/amd64/latest/amazon-cloudwatch-agent.rpm
|
| 174 |
+
yum update -y
|
| 175 |
+
yum install python3 -y
|
| 176 |
+
curl -O https://bootstrap.pypa.io/get-pip.py
|
| 177 |
+
# Install pip using python3
|
| 178 |
+
python3 get-pip.py
|
| 179 |
+
export PATH=$PATH:/usr/local/bin
|
| 180 |
+
pip3 install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz
|
| 181 |
+
cfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets default
|
| 182 |
+
cfn-signal -e $? --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region}
|
| 183 |
+
|
| 184 |
+
InstanceSecurityGroup:
|
| 185 |
+
Type: AWS::EC2::SecurityGroup
|
| 186 |
+
Properties:
|
| 187 |
+
GroupDescription: Enable SSH access via port 22
|
| 188 |
+
SecurityGroupIngress:
|
| 189 |
+
- IpProtocol: tcp
|
| 190 |
+
FromPort: "22"
|
| 191 |
+
ToPort: "22"
|
| 192 |
+
CidrIp: !Ref SSHLocation
|
human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/inline/suse.json
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"AWSTemplateFormatVersion": "2010-09-09",
|
| 3 |
+
"Description": "Template to install CloudWatchAgent on suse. It was validated on suse 12",
|
| 4 |
+
"Parameters": {
|
| 5 |
+
"KeyName": {
|
| 6 |
+
"Description": "Name of an existing EC2 KeyPair to enable SSH access to the instance",
|
| 7 |
+
"Type": "AWS::EC2::KeyPair::KeyName",
|
| 8 |
+
"ConstraintDescription": "must be the name of an existing EC2 KeyPair."
|
| 9 |
+
},
|
| 10 |
+
"InstanceType": {
|
| 11 |
+
"Description": "EC2 instance type",
|
| 12 |
+
"Type": "String",
|
| 13 |
+
"Default": "t3.medium",
|
| 14 |
+
"ConstraintDescription": "must be a valid EC2 instance type."
|
| 15 |
+
},
|
| 16 |
+
"SUSEVersion": {
|
| 17 |
+
"Type": "String",
|
| 18 |
+
"AllowedValues": [
|
| 19 |
+
"SLES15SP5"
|
| 20 |
+
],
|
| 21 |
+
"Default": "SLES15SP5",
|
| 22 |
+
"Description": "SUSE Linux Enterprise Server version to deploy"
|
| 23 |
+
},
|
| 24 |
+
"IAMRole": {
|
| 25 |
+
"Description": "EC2 attached IAM role",
|
| 26 |
+
"Type": "String",
|
| 27 |
+
"Default": "CloudWatchAgentAdminRole",
|
| 28 |
+
"ConstraintDescription": "must be an existing IAM role which will be attached to EC2 instance."
|
| 29 |
+
},
|
| 30 |
+
"SSHLocation": {
|
| 31 |
+
"Description": "The IP address range that can be used to SSH to the EC2 instances",
|
| 32 |
+
"Type": "String",
|
| 33 |
+
"Default": "0.0.0.0/0",
|
| 34 |
+
"MinLength": "9",
|
| 35 |
+
"MaxLength": "18",
|
| 36 |
+
"AllowedPattern": "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})",
|
| 37 |
+
"ConstraintDescription": "must be a valid IP CIDR range of the form x.x.x.x/x."
|
| 38 |
+
},
|
| 39 |
+
"SubnetId": {
|
| 40 |
+
"Type": "AWS::EC2::Subnet::Id"
|
| 41 |
+
}
|
| 42 |
+
},
|
| 43 |
+
"Mappings": {
|
| 44 |
+
"RegionMap": {
|
| 45 |
+
"us-east-1": {
|
| 46 |
+
"SLES15SP5": "ami-0d62a8e6541a2d491"
|
| 47 |
+
},
|
| 48 |
+
"us-east-2": {
|
| 49 |
+
"SLES15SP5": "ami-05d1f1c3db2b2eb0c"
|
| 50 |
+
},
|
| 51 |
+
"us-west-1": {
|
| 52 |
+
"SLES15SP5": "ami-060034d187be82d31"
|
| 53 |
+
},
|
| 54 |
+
"us-west-2": {
|
| 55 |
+
"SLES15SP5": "ami-066c85d277ae33d38"
|
| 56 |
+
},
|
| 57 |
+
"eu-west-1": {
|
| 58 |
+
"SLES15SP5": "ami-028867095499bce4b"
|
| 59 |
+
},
|
| 60 |
+
"eu-west-2": {
|
| 61 |
+
"RHEL9": "ami-03d783398e1e54eb1"
|
| 62 |
+
},
|
| 63 |
+
"ap-northeast-1": {
|
| 64 |
+
"RHEL9": "ami-05ef8ea5a07946994"
|
| 65 |
+
},
|
| 66 |
+
"ap-northeast-2": {
|
| 67 |
+
"RHEL9": "ami-0f8bf550807d8d01a"
|
| 68 |
+
},
|
| 69 |
+
"ap-southeast-1": {
|
| 70 |
+
"RHEL9": "ami-0db03992e79210b9f"
|
| 71 |
+
},
|
| 72 |
+
"ap-southeast-2": {
|
| 73 |
+
"RHEL9": "ami-084fd76702fabcf2c"
|
| 74 |
+
}
|
| 75 |
+
}
|
| 76 |
+
},
|
| 77 |
+
"Resources": {
|
| 78 |
+
"EC2Instance": {
|
| 79 |
+
"CreationPolicy": {
|
| 80 |
+
"ResourceSignal": {
|
| 81 |
+
"Count": 1,
|
| 82 |
+
"Timeout": "PT15M"
|
| 83 |
+
}
|
| 84 |
+
},
|
| 85 |
+
"Type": "AWS::EC2::Instance",
|
| 86 |
+
"Metadata": {
|
| 87 |
+
"AWS::CloudFormation::Init": {
|
| 88 |
+
"configSets": {
|
| 89 |
+
"default": [
|
| 90 |
+
"01_setupCfnHup",
|
| 91 |
+
"02_config-amazon-cloudwatch-agent",
|
| 92 |
+
"03_restart_amazon-cloudwatch-agent"
|
| 93 |
+
],
|
| 94 |
+
"UpdateEnvironment": [
|
| 95 |
+
"02_config-amazon-cloudwatch-agent",
|
| 96 |
+
"03_restart_amazon-cloudwatch-agent"
|
| 97 |
+
]
|
| 98 |
+
},
|
| 99 |
+
"02_config-amazon-cloudwatch-agent": {
|
| 100 |
+
"files": {
|
| 101 |
+
"/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json": {
|
| 102 |
+
"content": "{\n \"metrics\": {\n \"append_dimensions\": {\n \"AutoScalingGroupName\": \"${!aws:AutoScalingGroupName}\",\n \"ImageId\": \"${!aws:ImageId}\",\n \"InstanceId\": \"${!aws:InstanceId}\",\n \"InstanceType\": \"${!aws:InstanceType}\"\n },\n \"metrics_collected\": {\n \"mem\": {\n \"measurement\": [\n \"mem_used_percent\"\n ]\n },\n \"swap\": {\n \"measurement\": [\n \"swap_used_percent\"\n ]\n }\n }\n }\n}\n"
|
| 103 |
+
}
|
| 104 |
+
}
|
| 105 |
+
},
|
| 106 |
+
"03_restart_amazon-cloudwatch-agent": {
|
| 107 |
+
"commands": {
|
| 108 |
+
"01_stop_service": {
|
| 109 |
+
"command": "/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a stop"
|
| 110 |
+
},
|
| 111 |
+
"02_start_service": {
|
| 112 |
+
"command": "/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json -s"
|
| 113 |
+
}
|
| 114 |
+
}
|
| 115 |
+
},
|
| 116 |
+
"01_setupCfnHup": {
|
| 117 |
+
"files": {
|
| 118 |
+
"/etc/cfn/cfn-hup.conf": {
|
| 119 |
+
"content": {
|
| 120 |
+
"Fn::Sub": "[main]\nstack=${AWS::StackId}\nregion=${AWS::Region}\ninterval=1\n"
|
| 121 |
+
},
|
| 122 |
+
"mode": "000400",
|
| 123 |
+
"owner": "root",
|
| 124 |
+
"group": "root"
|
| 125 |
+
},
|
| 126 |
+
"/etc/cfn/hooks.d/amazon-cloudwatch-agent-auto-reloader.conf": {
|
| 127 |
+
"content": {
|
| 128 |
+
"Fn::Sub": "[cfn-auto-reloader-hook]\ntriggers=post.update\npath=Resources.EC2Instance.Metadata.AWS::CloudFormation::Init.02_config-amazon-cloudwatch-agent\naction=/opt/aws/bin/cfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets UpdateEnvironment\nrunas=root\n"
|
| 129 |
+
},
|
| 130 |
+
"mode": "000400",
|
| 131 |
+
"owner": "root",
|
| 132 |
+
"group": "root"
|
| 133 |
+
},
|
| 134 |
+
"/lib/systemd/system/cfn-hup.service": {
|
| 135 |
+
"content": "[Unit]\nDescription=cfn-hup daemon\n[Service]\nType=simple\nExecStart=/opt/aws/bin/cfn-hup\nRestart=always\n[Install]\nWantedBy=multi-user.target\n"
|
| 136 |
+
}
|
| 137 |
+
},
|
| 138 |
+
"commands": {
|
| 139 |
+
"01enable_cfn_hup": {
|
| 140 |
+
"command": "systemctl enable cfn-hup.service"
|
| 141 |
+
},
|
| 142 |
+
"02start_cfn_hup": {
|
| 143 |
+
"command": "systemctl start cfn-hup.service"
|
| 144 |
+
}
|
| 145 |
+
}
|
| 146 |
+
}
|
| 147 |
+
}
|
| 148 |
+
},
|
| 149 |
+
"Properties": {
|
| 150 |
+
"InstanceType": {
|
| 151 |
+
"Ref": "InstanceType"
|
| 152 |
+
},
|
| 153 |
+
"IamInstanceProfile": {
|
| 154 |
+
"Ref": "IAMRole"
|
| 155 |
+
},
|
| 156 |
+
"KeyName": {
|
| 157 |
+
"Ref": "KeyName"
|
| 158 |
+
},
|
| 159 |
+
"ImageId": {
|
| 160 |
+
"Fn::FindInMap": [
|
| 161 |
+
"RegionMap",
|
| 162 |
+
{
|
| 163 |
+
"Ref": "AWS::Region"
|
| 164 |
+
},
|
| 165 |
+
{
|
| 166 |
+
"Ref": "SUSEVersion"
|
| 167 |
+
}
|
| 168 |
+
]
|
| 169 |
+
},
|
| 170 |
+
"SubnetId": {
|
| 171 |
+
"Ref": "SubnetId"
|
| 172 |
+
},
|
| 173 |
+
"SecurityGroupIds": [
|
| 174 |
+
{
|
| 175 |
+
|
| 176 |
+
"Fn::GetAtt" : [ "InstanceSecurityGroup", "GroupId" ]
|
| 177 |
+
}
|
| 178 |
+
],
|
| 179 |
+
"UserData": {
|
| 180 |
+
"Fn::Base64": {
|
| 181 |
+
"Fn::Sub": "#!/bin/bash\nrpm -Uvh https://s3.amazonaws.com/amazoncloudwatch-agent/suse/amd64/latest/amazon-cloudwatch-agent.rpm\ncurl -O https://bootstrap.pypa.io/pip/3.6/get-pip.py\n# Install pip using python3\npython3 get-pip.py\nexport PATH=$PATH:/usr/local/bin\npip3 install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz\ncfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets default\ncfn-signal -e $? --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region}\n"
|
| 182 |
+
}
|
| 183 |
+
}
|
| 184 |
+
}
|
| 185 |
+
},
|
| 186 |
+
"InstanceSecurityGroup": {
|
| 187 |
+
"Type": "AWS::EC2::SecurityGroup",
|
| 188 |
+
"Properties": {
|
| 189 |
+
"GroupDescription": "Enable SSH access via port 22",
|
| 190 |
+
"SecurityGroupIngress": [
|
| 191 |
+
{
|
| 192 |
+
"IpProtocol": "tcp",
|
| 193 |
+
"FromPort": "22",
|
| 194 |
+
"ToPort": "22",
|
| 195 |
+
"CidrIp": {
|
| 196 |
+
"Ref": "SSHLocation"
|
| 197 |
+
}
|
| 198 |
+
}
|
| 199 |
+
]
|
| 200 |
+
}
|
| 201 |
+
}
|
| 202 |
+
}
|
| 203 |
+
}
|
human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/inline/suse.yaml
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
AWSTemplateFormatVersion: "2010-09-09"
|
| 2 |
+
|
| 3 |
+
Description: Template to install CloudWatchAgent on suse. It was validated on suse 12
|
| 4 |
+
|
| 5 |
+
Parameters:
|
| 6 |
+
KeyName:
|
| 7 |
+
Description: Name of an existing EC2 KeyPair to enable SSH access to the instance
|
| 8 |
+
Type: AWS::EC2::KeyPair::KeyName
|
| 9 |
+
ConstraintDescription: must be the name of an existing EC2 KeyPair.
|
| 10 |
+
|
| 11 |
+
InstanceType:
|
| 12 |
+
Description: EC2 instance type
|
| 13 |
+
Type: String
|
| 14 |
+
Default: t3.medium
|
| 15 |
+
ConstraintDescription: must be a valid EC2 instance type.
|
| 16 |
+
|
| 17 |
+
SUSEVersion:
|
| 18 |
+
Type: String
|
| 19 |
+
AllowedValues:
|
| 20 |
+
- SLES15SP5
|
| 21 |
+
Default: SLES15SP5
|
| 22 |
+
Description: SUSE Linux Enterprise Server version to deploy
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
IAMRole:
|
| 26 |
+
Description: EC2 attached IAM role
|
| 27 |
+
Type: String
|
| 28 |
+
Default: CloudWatchAgentAdminRole
|
| 29 |
+
ConstraintDescription: must be an existing IAM role which will be attached to EC2 instance.
|
| 30 |
+
|
| 31 |
+
SSHLocation:
|
| 32 |
+
Description: The IP address range that can be used to SSH to the EC2 instances
|
| 33 |
+
Type: String
|
| 34 |
+
Default: 0.0.0.0/0
|
| 35 |
+
MinLength: "9"
|
| 36 |
+
MaxLength: "18"
|
| 37 |
+
AllowedPattern: (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/(\d{1,2})
|
| 38 |
+
ConstraintDescription: must be a valid IP CIDR range of the form x.x.x.x/x.
|
| 39 |
+
|
| 40 |
+
SubnetId:
|
| 41 |
+
Type: AWS::EC2::Subnet::Id
|
| 42 |
+
|
| 43 |
+
Mappings:
|
| 44 |
+
RegionMap:
|
| 45 |
+
us-east-1:
|
| 46 |
+
SLES15SP5: ami-0d62a8e6541a2d491
|
| 47 |
+
us-east-2:
|
| 48 |
+
SLES15SP5: ami-05d1f1c3db2b2eb0c
|
| 49 |
+
us-west-1:
|
| 50 |
+
SLES15SP5: ami-060034d187be82d31
|
| 51 |
+
us-west-2:
|
| 52 |
+
SLES15SP5: ami-066c85d277ae33d38
|
| 53 |
+
eu-west-1:
|
| 54 |
+
SLES15SP5: ami-028867095499bce4b
|
| 55 |
+
eu-west-2:
|
| 56 |
+
SLES15SP5: ami-03d783398e1e54eb1
|
| 57 |
+
ap-northeast-1:
|
| 58 |
+
SLES15SP5: ami-05ef8ea5a07946994
|
| 59 |
+
ap-northeast-2:
|
| 60 |
+
SLES15SP5: ami-0f8bf550807d8d01a
|
| 61 |
+
ap-southeast-1:
|
| 62 |
+
SLES15SP5: ami-0db03992e79210b9f
|
| 63 |
+
ap-southeast-2:
|
| 64 |
+
SLES15SP5: ami-084fd76702fabcf2c
|
| 65 |
+
|
| 66 |
+
Resources:
|
| 67 |
+
EC2Instance:
|
| 68 |
+
CreationPolicy:
|
| 69 |
+
ResourceSignal:
|
| 70 |
+
Count: 1
|
| 71 |
+
Timeout: PT15M
|
| 72 |
+
Type: AWS::EC2::Instance
|
| 73 |
+
Metadata:
|
| 74 |
+
AWS::CloudFormation::Init:
|
| 75 |
+
configSets:
|
| 76 |
+
default:
|
| 77 |
+
- 01_setupCfnHup
|
| 78 |
+
- 02_config-amazon-cloudwatch-agent
|
| 79 |
+
- 03_restart_amazon-cloudwatch-agent
|
| 80 |
+
UpdateEnvironment:
|
| 81 |
+
- 02_config-amazon-cloudwatch-agent
|
| 82 |
+
- 03_restart_amazon-cloudwatch-agent
|
| 83 |
+
|
| 84 |
+
# Definition of json configuration of AmazonCloudWatchAgent, you can change the configuration below.
|
| 85 |
+
02_config-amazon-cloudwatch-agent:
|
| 86 |
+
files:
|
| 87 |
+
/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json:
|
| 88 |
+
content: |
|
| 89 |
+
{
|
| 90 |
+
"metrics": {
|
| 91 |
+
"append_dimensions": {
|
| 92 |
+
"AutoScalingGroupName": "${!aws:AutoScalingGroupName}",
|
| 93 |
+
"ImageId": "${!aws:ImageId}",
|
| 94 |
+
"InstanceId": "${!aws:InstanceId}",
|
| 95 |
+
"InstanceType": "${!aws:InstanceType}"
|
| 96 |
+
},
|
| 97 |
+
"metrics_collected": {
|
| 98 |
+
"mem": {
|
| 99 |
+
"measurement": [
|
| 100 |
+
"mem_used_percent"
|
| 101 |
+
]
|
| 102 |
+
},
|
| 103 |
+
"swap": {
|
| 104 |
+
"measurement": [
|
| 105 |
+
"swap_used_percent"
|
| 106 |
+
]
|
| 107 |
+
}
|
| 108 |
+
}
|
| 109 |
+
}
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
# Invoke amazon-cloudwatch-agent-ctl to restart the AmazonCloudWatchAgent.
|
| 113 |
+
03_restart_amazon-cloudwatch-agent:
|
| 114 |
+
commands:
|
| 115 |
+
01_stop_service:
|
| 116 |
+
command: /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a stop
|
| 117 |
+
02_start_service:
|
| 118 |
+
command: /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json -s
|
| 119 |
+
|
| 120 |
+
# Cfn-hup setting, it is to monitor the change of metadata.
|
| 121 |
+
# When there is change in the contents of json file in the metadata section, cfn-hup will call cfn-init to restart the AmazonCloudWatchAgent.
|
| 122 |
+
01_setupCfnHup:
|
| 123 |
+
files:
|
| 124 |
+
/etc/cfn/cfn-hup.conf:
|
| 125 |
+
content: !Sub |
|
| 126 |
+
[main]
|
| 127 |
+
stack=${AWS::StackId}
|
| 128 |
+
region=${AWS::Region}
|
| 129 |
+
interval=1
|
| 130 |
+
mode: "000400"
|
| 131 |
+
owner: root
|
| 132 |
+
group: root
|
| 133 |
+
/etc/cfn/hooks.d/amazon-cloudwatch-agent-auto-reloader.conf:
|
| 134 |
+
content: !Sub |
|
| 135 |
+
[cfn-auto-reloader-hook]
|
| 136 |
+
triggers=post.update
|
| 137 |
+
path=Resources.EC2Instance.Metadata.AWS::CloudFormation::Init.02_config-amazon-cloudwatch-agent
|
| 138 |
+
action=/opt/aws/bin/cfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets UpdateEnvironment
|
| 139 |
+
runas=root
|
| 140 |
+
mode: "000400"
|
| 141 |
+
owner: root
|
| 142 |
+
group: root
|
| 143 |
+
/lib/systemd/system/cfn-hup.service:
|
| 144 |
+
content: |
|
| 145 |
+
[Unit]
|
| 146 |
+
Description=cfn-hup daemon
|
| 147 |
+
[Service]
|
| 148 |
+
Type=simple
|
| 149 |
+
ExecStart=/opt/aws/bin/cfn-hup
|
| 150 |
+
Restart=always
|
| 151 |
+
[Install]
|
| 152 |
+
WantedBy=multi-user.target
|
| 153 |
+
commands:
|
| 154 |
+
01enable_cfn_hup:
|
| 155 |
+
command: systemctl enable cfn-hup.service
|
| 156 |
+
02start_cfn_hup:
|
| 157 |
+
command: systemctl start cfn-hup.service
|
| 158 |
+
Properties:
|
| 159 |
+
InstanceType: !Ref InstanceType
|
| 160 |
+
IamInstanceProfile: !Ref IAMRole
|
| 161 |
+
KeyName: !Ref KeyName
|
| 162 |
+
ImageId: !FindInMap
|
| 163 |
+
- RegionMap
|
| 164 |
+
- !Ref 'AWS::Region'
|
| 165 |
+
- !Ref SUSEVersion
|
| 166 |
+
SubnetId: !Ref SubnetId
|
| 167 |
+
SecurityGroupIds:
|
| 168 |
+
- !GetAtt InstanceSecurityGroup.GroupId
|
| 169 |
+
UserData: !Base64
|
| 170 |
+
Fn::Sub: |
|
| 171 |
+
#!/bin/bash
|
| 172 |
+
rpm -Uvh https://s3.amazonaws.com/amazoncloudwatch-agent/suse/amd64/latest/amazon-cloudwatch-agent.rpm
|
| 173 |
+
curl -O https://bootstrap.pypa.io/pip/3.6/get-pip.py
|
| 174 |
+
# Install pip using python3
|
| 175 |
+
python3 get-pip.py
|
| 176 |
+
export PATH=$PATH:/usr/local/bin
|
| 177 |
+
pip3 install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz
|
| 178 |
+
cfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets default
|
| 179 |
+
cfn-signal -e $? --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region}
|
| 180 |
+
|
| 181 |
+
InstanceSecurityGroup:
|
| 182 |
+
Type: AWS::EC2::SecurityGroup
|
| 183 |
+
Properties:
|
| 184 |
+
GroupDescription: Enable SSH access via port 22
|
| 185 |
+
SecurityGroupIngress:
|
| 186 |
+
- IpProtocol: tcp
|
| 187 |
+
FromPort: "22"
|
| 188 |
+
ToPort: "22"
|
| 189 |
+
CidrIp: !Ref SSHLocation
|
human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/inline/ubuntu.json
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"AWSTemplateFormatVersion": "2010-09-09",
|
| 3 |
+
"Description": "Template to install CloudWatchAgent on ubuntu. It was validated on ubuntu 22.04",
|
| 4 |
+
"Parameters": {
|
| 5 |
+
"KeyName": {
|
| 6 |
+
"Description": "Name of an existing EC2 KeyPair to enable SSH access to the instance",
|
| 7 |
+
"Type": "AWS::EC2::KeyPair::KeyName",
|
| 8 |
+
"ConstraintDescription": "must be the name of an existing EC2 KeyPair."
|
| 9 |
+
},
|
| 10 |
+
"InstanceType": {
|
| 11 |
+
"Description": "EC2 instance type",
|
| 12 |
+
"Type": "String",
|
| 13 |
+
"Default": "t3.medium",
|
| 14 |
+
"ConstraintDescription": "must be a valid EC2 instance type."
|
| 15 |
+
},
|
| 16 |
+
"InstanceAMI": {
|
| 17 |
+
"Description": "Managed AMI ID for EC2 Instance",
|
| 18 |
+
"Type": "AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>",
|
| 19 |
+
"Default": "/aws/service/canonical/ubuntu/eks-pro/22.04/1.29/stable/current/amd64/hvm/ebs-gp2/ami-id"
|
| 20 |
+
},
|
| 21 |
+
"IAMRole": {
|
| 22 |
+
"Description": "EC2 attached IAM role",
|
| 23 |
+
"Type": "String",
|
| 24 |
+
"Default": "CloudWatchAgentAdminRole",
|
| 25 |
+
"ConstraintDescription": "must be an existing IAM role which will be attached to EC2 instance."
|
| 26 |
+
},
|
| 27 |
+
"SSHLocation": {
|
| 28 |
+
"Description": "The IP address range that can be used to SSH to the EC2 instances",
|
| 29 |
+
"Type": "String",
|
| 30 |
+
"Default": "0.0.0.0/0",
|
| 31 |
+
"MinLength": "9",
|
| 32 |
+
"MaxLength": "18",
|
| 33 |
+
"AllowedPattern": "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})",
|
| 34 |
+
"ConstraintDescription": "must be a valid IP CIDR range of the form x.x.x.x/x."
|
| 35 |
+
},
|
| 36 |
+
"SubnetId": {
|
| 37 |
+
"Type": "AWS::EC2::Subnet::Id"
|
| 38 |
+
}
|
| 39 |
+
},
|
| 40 |
+
"Resources": {
|
| 41 |
+
"EC2Instance": {
|
| 42 |
+
"CreationPolicy": {
|
| 43 |
+
"ResourceSignal": {
|
| 44 |
+
"Count": 1,
|
| 45 |
+
"Timeout": "PT15M"
|
| 46 |
+
}
|
| 47 |
+
},
|
| 48 |
+
"Type": "AWS::EC2::Instance",
|
| 49 |
+
"Metadata": {
|
| 50 |
+
"AWS::CloudFormation::Init": {
|
| 51 |
+
"configSets": {
|
| 52 |
+
"default": [
|
| 53 |
+
"01_setupCfnHup",
|
| 54 |
+
"02_config-amazon-cloudwatch-agent",
|
| 55 |
+
"03_restart_amazon-cloudwatch-agent"
|
| 56 |
+
],
|
| 57 |
+
"UpdateEnvironment": [
|
| 58 |
+
"02_config-amazon-cloudwatch-agent",
|
| 59 |
+
"03_restart_amazon-cloudwatch-agent"
|
| 60 |
+
]
|
| 61 |
+
},
|
| 62 |
+
"02_config-amazon-cloudwatch-agent": {
|
| 63 |
+
"files": {
|
| 64 |
+
"/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json": {
|
| 65 |
+
"content": "{\n \"metrics\": {\n \"append_dimensions\": {\n \"AutoScalingGroupName\": \"${!aws:AutoScalingGroupName}\",\n \"ImageId\": \"${!aws:ImageId}\",\n \"InstanceId\": \"${!aws:InstanceId}\",\n \"InstanceType\": \"${!aws:InstanceType}\"\n },\n \"metrics_collected\": {\n \"mem\": {\n \"measurement\": [\n \"mem_used_percent\"\n ]\n },\n \"swap\": {\n \"measurement\": [\n \"swap_used_percent\"\n ]\n }\n }\n }\n}\n"
|
| 66 |
+
}
|
| 67 |
+
}
|
| 68 |
+
},
|
| 69 |
+
"03_restart_amazon-cloudwatch-agent": {
|
| 70 |
+
"commands": {
|
| 71 |
+
"01_stop_service": {
|
| 72 |
+
"command": "/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a stop"
|
| 73 |
+
},
|
| 74 |
+
"02_start_service": {
|
| 75 |
+
"command": "/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json -s"
|
| 76 |
+
}
|
| 77 |
+
}
|
| 78 |
+
},
|
| 79 |
+
"01_setupCfnHup": {
|
| 80 |
+
"files": {
|
| 81 |
+
"/etc/cfn/cfn-hup.conf": {
|
| 82 |
+
"content": {
|
| 83 |
+
"Fn::Sub": "[main]\nstack=${AWS::StackId}\nregion=${AWS::Region}\ninterval=1\n"
|
| 84 |
+
},
|
| 85 |
+
"mode": "000400",
|
| 86 |
+
"owner": "root",
|
| 87 |
+
"group": "root"
|
| 88 |
+
},
|
| 89 |
+
"/etc/cfn/hooks.d/amazon-cloudwatch-agent-auto-reloader.conf": {
|
| 90 |
+
"content": {
|
| 91 |
+
"Fn::Sub": "[cfn-auto-reloader-hook]\ntriggers=post.update\npath=Resources.EC2Instance.Metadata.AWS::CloudFormation::Init.02_config-amazon-cloudwatch-agent\naction=/opt/aws/bin/cfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets UpdateEnvironment\nrunas=root\n"
|
| 92 |
+
},
|
| 93 |
+
"mode": "000400",
|
| 94 |
+
"owner": "root",
|
| 95 |
+
"group": "root"
|
| 96 |
+
},
|
| 97 |
+
"/lib/systemd/system/cfn-hup.service": {
|
| 98 |
+
"content": "[Unit]\nDescription=cfn-hup daemon\n[Service]\nType=simple\nExecStart=/opt/aws/bin/cfn-hup\nRestart=always\n[Install]\nWantedBy=multi-user.target\n"
|
| 99 |
+
}
|
| 100 |
+
},
|
| 101 |
+
"commands": {
|
| 102 |
+
"01enable_cfn_hup": {
|
| 103 |
+
"command": "systemctl enable cfn-hup.service"
|
| 104 |
+
},
|
| 105 |
+
"02start_cfn_hup": {
|
| 106 |
+
"command": "systemctl start cfn-hup.service"
|
| 107 |
+
}
|
| 108 |
+
}
|
| 109 |
+
}
|
| 110 |
+
}
|
| 111 |
+
},
|
| 112 |
+
"Properties": {
|
| 113 |
+
"InstanceType": {
|
| 114 |
+
"Ref": "InstanceType"
|
| 115 |
+
},
|
| 116 |
+
"IamInstanceProfile": {
|
| 117 |
+
"Ref": "IAMRole"
|
| 118 |
+
},
|
| 119 |
+
"KeyName": {
|
| 120 |
+
"Ref": "KeyName"
|
| 121 |
+
},
|
| 122 |
+
"ImageId": {
|
| 123 |
+
"Ref": "InstanceAMI"
|
| 124 |
+
},
|
| 125 |
+
"SubnetId": {
|
| 126 |
+
"Ref": "SubnetId"
|
| 127 |
+
},
|
| 128 |
+
"SecurityGroupIds": [
|
| 129 |
+
{
|
| 130 |
+
|
| 131 |
+
"Fn::GetAtt" : [ "InstanceSecurityGroup", "GroupId" ]
|
| 132 |
+
}
|
| 133 |
+
],
|
| 134 |
+
"UserData": {
|
| 135 |
+
"Fn::Base64": {
|
| 136 |
+
"Fn::Sub": "#!/bin/bash\nwget https://s3.amazonaws.com/amazoncloudwatch-agent/ubuntu/amd64/latest/amazon-cloudwatch-agent.deb -O /tmp/amazon-cloudwatch-agent.deb\ndpkg -i /tmp/amazon-cloudwatch-agent.deb\napt-get update -y\napt-get install -y python3 python3-pip\npip3 install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz\ncfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets default\ncfn-signal -e $? --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region}\n"
|
| 137 |
+
}
|
| 138 |
+
}
|
| 139 |
+
}
|
| 140 |
+
},
|
| 141 |
+
"InstanceSecurityGroup": {
|
| 142 |
+
"Type": "AWS::EC2::SecurityGroup",
|
| 143 |
+
"Properties": {
|
| 144 |
+
"GroupDescription": "Enable SSH access via port 22",
|
| 145 |
+
"SecurityGroupIngress": [
|
| 146 |
+
{
|
| 147 |
+
"IpProtocol": "tcp",
|
| 148 |
+
"FromPort": "22",
|
| 149 |
+
"ToPort": "22",
|
| 150 |
+
"CidrIp": {
|
| 151 |
+
"Ref": "SSHLocation"
|
| 152 |
+
}
|
| 153 |
+
}
|
| 154 |
+
]
|
| 155 |
+
}
|
| 156 |
+
}
|
| 157 |
+
}
|
| 158 |
+
}
|
human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/inline/ubuntu.yaml
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
AWSTemplateFormatVersion: "2010-09-09"
|
| 2 |
+
|
| 3 |
+
Description: Template to install CloudWatchAgent on ubuntu. It was validated on ubuntu 22.04
|
| 4 |
+
|
| 5 |
+
Parameters:
|
| 6 |
+
KeyName:
|
| 7 |
+
Description: Name of an existing EC2 KeyPair to enable SSH access to the instance
|
| 8 |
+
Type: AWS::EC2::KeyPair::KeyName
|
| 9 |
+
ConstraintDescription: must be the name of an existing EC2 KeyPair.
|
| 10 |
+
|
| 11 |
+
InstanceType:
|
| 12 |
+
Description: EC2 instance type
|
| 13 |
+
Type: String
|
| 14 |
+
Default: t3.medium
|
| 15 |
+
ConstraintDescription: must be a valid EC2 instance type.
|
| 16 |
+
|
| 17 |
+
InstanceAMI:
|
| 18 |
+
Description: Managed AMI ID for EC2 Instance
|
| 19 |
+
Type: AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>
|
| 20 |
+
Default: /aws/service/canonical/ubuntu/eks-pro/22.04/1.29/stable/current/amd64/hvm/ebs-gp2/ami-id
|
| 21 |
+
|
| 22 |
+
IAMRole:
|
| 23 |
+
Description: EC2 attached IAM role
|
| 24 |
+
Type: String
|
| 25 |
+
Default: CloudWatchAgentAdminRole
|
| 26 |
+
ConstraintDescription: must be an existing IAM role which will be attached to EC2 instance.
|
| 27 |
+
|
| 28 |
+
SSHLocation:
|
| 29 |
+
Description: The IP address range that can be used to SSH to the EC2 instances
|
| 30 |
+
Type: String
|
| 31 |
+
Default: 0.0.0.0/0
|
| 32 |
+
MinLength: "9"
|
| 33 |
+
MaxLength: "18"
|
| 34 |
+
AllowedPattern: (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/(\d{1,2})
|
| 35 |
+
ConstraintDescription: must be a valid IP CIDR range of the form x.x.x.x/x.
|
| 36 |
+
|
| 37 |
+
SubnetId:
|
| 38 |
+
Type: AWS::EC2::Subnet::Id
|
| 39 |
+
|
| 40 |
+
Resources:
|
| 41 |
+
EC2Instance:
|
| 42 |
+
CreationPolicy:
|
| 43 |
+
ResourceSignal:
|
| 44 |
+
Count: 1
|
| 45 |
+
Timeout: PT15M
|
| 46 |
+
Type: AWS::EC2::Instance
|
| 47 |
+
Metadata:
|
| 48 |
+
AWS::CloudFormation::Init:
|
| 49 |
+
configSets:
|
| 50 |
+
default:
|
| 51 |
+
- 01_setupCfnHup
|
| 52 |
+
- 02_config-amazon-cloudwatch-agent
|
| 53 |
+
- 03_restart_amazon-cloudwatch-agent
|
| 54 |
+
UpdateEnvironment:
|
| 55 |
+
- 02_config-amazon-cloudwatch-agent
|
| 56 |
+
- 03_restart_amazon-cloudwatch-agent
|
| 57 |
+
|
| 58 |
+
# Definition of json configuration of AmazonCloudWatchAgent, you can change the configuration below.
|
| 59 |
+
02_config-amazon-cloudwatch-agent:
|
| 60 |
+
files:
|
| 61 |
+
/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json:
|
| 62 |
+
content: |
|
| 63 |
+
{
|
| 64 |
+
"metrics": {
|
| 65 |
+
"append_dimensions": {
|
| 66 |
+
"AutoScalingGroupName": "${!aws:AutoScalingGroupName}",
|
| 67 |
+
"ImageId": "${!aws:ImageId}",
|
| 68 |
+
"InstanceId": "${!aws:InstanceId}",
|
| 69 |
+
"InstanceType": "${!aws:InstanceType}"
|
| 70 |
+
},
|
| 71 |
+
"metrics_collected": {
|
| 72 |
+
"mem": {
|
| 73 |
+
"measurement": [
|
| 74 |
+
"mem_used_percent"
|
| 75 |
+
]
|
| 76 |
+
},
|
| 77 |
+
"swap": {
|
| 78 |
+
"measurement": [
|
| 79 |
+
"swap_used_percent"
|
| 80 |
+
]
|
| 81 |
+
}
|
| 82 |
+
}
|
| 83 |
+
}
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
# Invoke amazon-cloudwatch-agent-ctl to restart the AmazonCloudWatchAgent.
|
| 87 |
+
03_restart_amazon-cloudwatch-agent:
|
| 88 |
+
commands:
|
| 89 |
+
01_stop_service:
|
| 90 |
+
command: /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a stop
|
| 91 |
+
02_start_service:
|
| 92 |
+
command: /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json -s
|
| 93 |
+
|
| 94 |
+
# Cfn-hup setting, it is to monitor the change of metadata.
|
| 95 |
+
# When there is change in the contents of json file in the metadata section, cfn-hup will call cfn-init to restart the AmazonCloudWatchAgent.
|
| 96 |
+
01_setupCfnHup:
|
| 97 |
+
files:
|
| 98 |
+
/etc/cfn/cfn-hup.conf:
|
| 99 |
+
content: !Sub |
|
| 100 |
+
[main]
|
| 101 |
+
stack=${AWS::StackId}
|
| 102 |
+
region=${AWS::Region}
|
| 103 |
+
interval=1
|
| 104 |
+
mode: "000400"
|
| 105 |
+
owner: root
|
| 106 |
+
group: root
|
| 107 |
+
/etc/cfn/hooks.d/amazon-cloudwatch-agent-auto-reloader.conf:
|
| 108 |
+
content: !Sub |
|
| 109 |
+
[cfn-auto-reloader-hook]
|
| 110 |
+
triggers=post.update
|
| 111 |
+
path=Resources.EC2Instance.Metadata.AWS::CloudFormation::Init.02_config-amazon-cloudwatch-agent
|
| 112 |
+
action=/opt/aws/bin/cfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets UpdateEnvironment
|
| 113 |
+
runas=root
|
| 114 |
+
mode: "000400"
|
| 115 |
+
owner: root
|
| 116 |
+
group: root
|
| 117 |
+
/lib/systemd/system/cfn-hup.service:
|
| 118 |
+
content: |
|
| 119 |
+
[Unit]
|
| 120 |
+
Description=cfn-hup daemon
|
| 121 |
+
[Service]
|
| 122 |
+
Type=simple
|
| 123 |
+
ExecStart=/opt/aws/bin/cfn-hup
|
| 124 |
+
Restart=always
|
| 125 |
+
[Install]
|
| 126 |
+
WantedBy=multi-user.target
|
| 127 |
+
commands:
|
| 128 |
+
01enable_cfn_hup:
|
| 129 |
+
command: systemctl enable cfn-hup.service
|
| 130 |
+
02start_cfn_hup:
|
| 131 |
+
command: systemctl start cfn-hup.service
|
| 132 |
+
Properties:
|
| 133 |
+
InstanceType: !Ref InstanceType
|
| 134 |
+
IamInstanceProfile: !Ref IAMRole
|
| 135 |
+
KeyName: !Ref KeyName
|
| 136 |
+
ImageId: !Ref InstanceAMI
|
| 137 |
+
SubnetId: !Ref SubnetId
|
| 138 |
+
SecurityGroupIds:
|
| 139 |
+
- !GetAtt InstanceSecurityGroup.GroupId
|
| 140 |
+
UserData: !Base64
|
| 141 |
+
Fn::Sub: |
|
| 142 |
+
#!/bin/bash
|
| 143 |
+
wget https://s3.amazonaws.com/amazoncloudwatch-agent/ubuntu/amd64/latest/amazon-cloudwatch-agent.deb -O /tmp/amazon-cloudwatch-agent.deb
|
| 144 |
+
dpkg -i /tmp/amazon-cloudwatch-agent.deb
|
| 145 |
+
apt-get update -y
|
| 146 |
+
apt-get install -y python3 python3-pip
|
| 147 |
+
pip3 install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz
|
| 148 |
+
cfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets default
|
| 149 |
+
cfn-signal -e $? --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region}
|
| 150 |
+
|
| 151 |
+
InstanceSecurityGroup:
|
| 152 |
+
Type: AWS::EC2::SecurityGroup
|
| 153 |
+
Properties:
|
| 154 |
+
GroupDescription: Enable SSH access via port 22
|
| 155 |
+
SecurityGroupIngress:
|
| 156 |
+
- IpProtocol: tcp
|
| 157 |
+
FromPort: "22"
|
| 158 |
+
ToPort: "22"
|
| 159 |
+
CidrIp: !Ref SSHLocation
|
human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/inline/windows.json
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"AWSTemplateFormatVersion": "2010-09-09",
|
| 3 |
+
"Description": "Template to install CloudWatchAgent on windows. It was validated on windows 2016",
|
| 4 |
+
"Parameters": {
|
| 5 |
+
"KeyName": {
|
| 6 |
+
"Description": "Name of an existing EC2 KeyPair to enable SSH access to the instance",
|
| 7 |
+
"Type": "AWS::EC2::KeyPair::KeyName",
|
| 8 |
+
"ConstraintDescription": "must be the name of an existing EC2 KeyPair."
|
| 9 |
+
},
|
| 10 |
+
"InstanceType": {
|
| 11 |
+
"Description": "EC2 instance type",
|
| 12 |
+
"Type": "String",
|
| 13 |
+
"Default": "t3.medium",
|
| 14 |
+
"ConstraintDescription": "must be a valid EC2 instance type."
|
| 15 |
+
},
|
| 16 |
+
"InstanceAMI": {
|
| 17 |
+
"Description": "Managed AMI ID for EC2 Instance",
|
| 18 |
+
"Type": "AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>",
|
| 19 |
+
"Default": "/aws/service/ami-windows-latest/Windows_Server-2022-English-Full-SQL_2022_Web"
|
| 20 |
+
},
|
| 21 |
+
"IAMRole": {
|
| 22 |
+
"Description": "EC2 attached IAM role",
|
| 23 |
+
"Type": "String",
|
| 24 |
+
"Default": "CloudWatchAgentAdminRole",
|
| 25 |
+
"ConstraintDescription": "must be an existing IAM role which will be attached to EC2 instance."
|
| 26 |
+
},
|
| 27 |
+
"SubnetId": {
|
| 28 |
+
"Type": "AWS::EC2::Subnet::Id"
|
| 29 |
+
}
|
| 30 |
+
},
|
| 31 |
+
"Resources": {
|
| 32 |
+
"EC2Instance": {
|
| 33 |
+
"CreationPolicy": {
|
| 34 |
+
"ResourceSignal": {
|
| 35 |
+
"Count": 1,
|
| 36 |
+
"Timeout": "PT15M"
|
| 37 |
+
}
|
| 38 |
+
},
|
| 39 |
+
"Type": "AWS::EC2::Instance",
|
| 40 |
+
"Metadata": {
|
| 41 |
+
"AWS::CloudFormation::Init": {
|
| 42 |
+
"configSets": {
|
| 43 |
+
"default": [
|
| 44 |
+
"00_setupCfnHup",
|
| 45 |
+
"01_CfnHup_service",
|
| 46 |
+
"02_config-amazon-cloudwatch-agent",
|
| 47 |
+
"03_restart_amazon-cloudwatch-agent"
|
| 48 |
+
],
|
| 49 |
+
"UpdateEnvironment": [
|
| 50 |
+
"02_config-amazon-cloudwatch-agent",
|
| 51 |
+
"03_restart_amazon-cloudwatch-agent"
|
| 52 |
+
]
|
| 53 |
+
},
|
| 54 |
+
"00_setupCfnHup": {
|
| 55 |
+
"files": {
|
| 56 |
+
"c:\\cfn\\cfn-hup.conf": {
|
| 57 |
+
"content": {
|
| 58 |
+
"Fn::Sub": "[main]\nstack=${AWS::StackId}\nregion=${AWS::Region}\ninterval=1\n"
|
| 59 |
+
}
|
| 60 |
+
},
|
| 61 |
+
"c:\\cfn\\hooks.d\\amazon-cloudwatch-agent-auto-reloader.conf": {
|
| 62 |
+
"content": {
|
| 63 |
+
"Fn::Sub": "[cfn-auto-reloader-hook]\ntriggers=post.update\npath=Resources.EC2Instance.Metadata.AWS::CloudFormation::Init.02_config-amazon-cloudwatch-agent\naction=cfn-init.exe -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets UpdateEnvironment\n"
|
| 64 |
+
}
|
| 65 |
+
}
|
| 66 |
+
}
|
| 67 |
+
},
|
| 68 |
+
"01_CfnHup_service": {
|
| 69 |
+
"services": {
|
| 70 |
+
"windows": {
|
| 71 |
+
"cfn-hup": {
|
| 72 |
+
"enabled": "true",
|
| 73 |
+
"ensureRunning": "true",
|
| 74 |
+
"files": [
|
| 75 |
+
"c:\\cfn\\cfn-hup.conf",
|
| 76 |
+
"c:\\cfn\\hooks.d\\cfn-auto-reloader.conf"
|
| 77 |
+
]
|
| 78 |
+
}
|
| 79 |
+
}
|
| 80 |
+
}
|
| 81 |
+
},
|
| 82 |
+
"02_config-amazon-cloudwatch-agent": {
|
| 83 |
+
"files": {
|
| 84 |
+
"C:\\ProgramData\\Amazon\\AmazonCloudWatchAgent\\amazon-cloudwatch-agent.json": {
|
| 85 |
+
"content": "{\n \"metrics\": {\n \"append_dimensions\": {\n \"AutoScalingGroupName\": \"${!aws:AutoScalingGroupName}\",\n \"ImageId\": \"${!aws:ImageId}\",\n \"InstanceId\": \"${!aws:InstanceId}\",\n \"InstanceType\": \"${!aws:InstanceType}\"\n },\n \"metrics_collected\": {\n \"Memory\": {\n \"measurement\": [\n \"% Committed Bytes In Use\"\n ],\n \"metrics_collection_interval\": 60\n },\n \"Paging File\": {\n \"measurement\": [\n \"% Usage\"\n ],\n \"metrics_collection_interval\": 60,\n \"resources\": [\n \"*\"\n ]\n }\n }\n }\n}\n"
|
| 86 |
+
}
|
| 87 |
+
}
|
| 88 |
+
},
|
| 89 |
+
"03_restart_amazon-cloudwatch-agent": {
|
| 90 |
+
"commands": {
|
| 91 |
+
"01_stop_service": {
|
| 92 |
+
"command": "powershell -Command \"C:\\\\'Program Files'\\\\Amazon\\\\AmazonCloudWatchAgent\\\\amazon-cloudwatch-agent-ctl.ps1 -a stop\""
|
| 93 |
+
},
|
| 94 |
+
"02_start_service": {
|
| 95 |
+
"command": "powershell -Command \"C:\\\\'Program Files'\\\\Amazon\\\\AmazonCloudWatchAgent\\\\amazon-cloudwatch-agent-ctl.ps1 -a fetch-config -m ec2 -c file:C:\\\\ProgramData\\\\Amazon\\\\AmazonCloudWatchAgent\\\\amazon-cloudwatch-agent.json -s\""
|
| 96 |
+
}
|
| 97 |
+
}
|
| 98 |
+
}
|
| 99 |
+
}
|
| 100 |
+
},
|
| 101 |
+
"Properties": {
|
| 102 |
+
"InstanceType": {
|
| 103 |
+
"Ref": "InstanceType"
|
| 104 |
+
},
|
| 105 |
+
"IamInstanceProfile": {
|
| 106 |
+
"Ref": "IAMRole"
|
| 107 |
+
},
|
| 108 |
+
"KeyName": {
|
| 109 |
+
"Ref": "KeyName"
|
| 110 |
+
},
|
| 111 |
+
"ImageId": {
|
| 112 |
+
"Ref": "InstanceAMI"
|
| 113 |
+
},
|
| 114 |
+
"SubnetId": {
|
| 115 |
+
"Ref": "SubnetId"
|
| 116 |
+
},
|
| 117 |
+
"UserData": {
|
| 118 |
+
"Fn::Base64": {
|
| 119 |
+
"Fn::Sub": "<script>\nmkdir C:\\Downloads\\Amazon\\AmazonCloudWatchAgent\npowershell -Command \"(New-Object Net.WebClient).DownloadFile('https://s3.amazonaws.com/amazoncloudwatch-agent/windows/amd64/latest/amazon-cloudwatch-agent.msi','C:\\Downloads\\Amazon\\AmazonCloudWatchAgent\\amazon-cloudwatch-agent.msi')\"\nC:\\Downloads\\Amazon\\AmazonCloudWatchAgent\\amazon-cloudwatch-agent.msi\ncfn-init.exe -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets default\ncfn-signal.exe -e %errorlevel% --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region}\n</script>"
|
| 120 |
+
}
|
| 121 |
+
}
|
| 122 |
+
}
|
| 123 |
+
}
|
| 124 |
+
}
|
| 125 |
+
}
|
human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/inline/windows.yaml
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
AWSTemplateFormatVersion: "2010-09-09"
|
| 2 |
+
|
| 3 |
+
Description: Template to install CloudWatchAgent on windows. It was validated on windows 2016
|
| 4 |
+
|
| 5 |
+
Parameters:
|
| 6 |
+
KeyName:
|
| 7 |
+
Description: Name of an existing EC2 KeyPair to enable SSH access to the instance
|
| 8 |
+
Type: AWS::EC2::KeyPair::KeyName
|
| 9 |
+
ConstraintDescription: must be the name of an existing EC2 KeyPair.
|
| 10 |
+
|
| 11 |
+
InstanceType:
|
| 12 |
+
Description: EC2 instance type
|
| 13 |
+
Type: String
|
| 14 |
+
Default: t3.medium
|
| 15 |
+
ConstraintDescription: must be a valid EC2 instance type.
|
| 16 |
+
|
| 17 |
+
InstanceAMI:
|
| 18 |
+
Description: Managed AMI ID for EC2 Instance
|
| 19 |
+
Type: AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>
|
| 20 |
+
Default: /aws/service/ami-windows-latest/Windows_Server-2022-English-Full-SQL_2022_Web
|
| 21 |
+
|
| 22 |
+
IAMRole:
|
| 23 |
+
Description: EC2 attached IAM role
|
| 24 |
+
Type: String
|
| 25 |
+
Default: CloudWatchAgentAdminRole
|
| 26 |
+
ConstraintDescription: must be an existing IAM role which will be attached to EC2 instance.
|
| 27 |
+
|
| 28 |
+
SubnetId:
|
| 29 |
+
Type: AWS::EC2::Subnet::Id
|
| 30 |
+
|
| 31 |
+
Resources:
|
| 32 |
+
EC2Instance:
|
| 33 |
+
CreationPolicy:
|
| 34 |
+
ResourceSignal:
|
| 35 |
+
Count: 1
|
| 36 |
+
Timeout: PT15M
|
| 37 |
+
Type: AWS::EC2::Instance
|
| 38 |
+
Metadata:
|
| 39 |
+
AWS::CloudFormation::Init:
|
| 40 |
+
configSets:
|
| 41 |
+
default:
|
| 42 |
+
- 00_setupCfnHup
|
| 43 |
+
- 01_CfnHup_service
|
| 44 |
+
- 02_config-amazon-cloudwatch-agent
|
| 45 |
+
- 03_restart_amazon-cloudwatch-agent
|
| 46 |
+
UpdateEnvironment:
|
| 47 |
+
- 02_config-amazon-cloudwatch-agent
|
| 48 |
+
- 03_restart_amazon-cloudwatch-agent
|
| 49 |
+
|
| 50 |
+
# Cfn-hup setting, it is to monitor the change of metadata.
|
| 51 |
+
# When there is change in the contents of json file in the metadata section, cfn-hup will call cfn-init to restart the AmazonCloudWatchAgent.
|
| 52 |
+
00_setupCfnHup:
|
| 53 |
+
files:
|
| 54 |
+
c:\cfn\cfn-hup.conf:
|
| 55 |
+
content: !Sub |
|
| 56 |
+
[main]
|
| 57 |
+
stack=${AWS::StackId}
|
| 58 |
+
region=${AWS::Region}
|
| 59 |
+
interval=1
|
| 60 |
+
c:\cfn\hooks.d\amazon-cloudwatch-agent-auto-reloader.conf:
|
| 61 |
+
content: !Sub |
|
| 62 |
+
[cfn-auto-reloader-hook]
|
| 63 |
+
triggers=post.update
|
| 64 |
+
path=Resources.EC2Instance.Metadata.AWS::CloudFormation::Init.02_config-amazon-cloudwatch-agent
|
| 65 |
+
action=cfn-init.exe -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets UpdateEnvironment
|
| 66 |
+
01_CfnHup_service:
|
| 67 |
+
services:
|
| 68 |
+
windows:
|
| 69 |
+
cfn-hup:
|
| 70 |
+
enabled: "true"
|
| 71 |
+
ensureRunning: "true"
|
| 72 |
+
files:
|
| 73 |
+
- c:\cfn\cfn-hup.conf
|
| 74 |
+
- c:\cfn\hooks.d\cfn-auto-reloader.conf
|
| 75 |
+
|
| 76 |
+
# Definition of json configuration of AmazonCloudWatchAgent, you can change the configuration below.
|
| 77 |
+
02_config-amazon-cloudwatch-agent:
|
| 78 |
+
files:
|
| 79 |
+
C:\ProgramData\Amazon\AmazonCloudWatchAgent\amazon-cloudwatch-agent.json:
|
| 80 |
+
content: |
|
| 81 |
+
{
|
| 82 |
+
"metrics": {
|
| 83 |
+
"append_dimensions": {
|
| 84 |
+
"AutoScalingGroupName": "${!aws:AutoScalingGroupName}",
|
| 85 |
+
"ImageId": "${!aws:ImageId}",
|
| 86 |
+
"InstanceId": "${!aws:InstanceId}",
|
| 87 |
+
"InstanceType": "${!aws:InstanceType}"
|
| 88 |
+
},
|
| 89 |
+
"metrics_collected": {
|
| 90 |
+
"Memory": {
|
| 91 |
+
"measurement": [
|
| 92 |
+
"% Committed Bytes In Use"
|
| 93 |
+
],
|
| 94 |
+
"metrics_collection_interval": 60
|
| 95 |
+
},
|
| 96 |
+
"Paging File": {
|
| 97 |
+
"measurement": [
|
| 98 |
+
"% Usage"
|
| 99 |
+
],
|
| 100 |
+
"metrics_collection_interval": 60,
|
| 101 |
+
"resources": [
|
| 102 |
+
"*"
|
| 103 |
+
]
|
| 104 |
+
}
|
| 105 |
+
}
|
| 106 |
+
}
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
# Invoke amazon-cloudwatch-agent-ctl to restart the AmazonCloudWatchAgent.
|
| 110 |
+
03_restart_amazon-cloudwatch-agent:
|
| 111 |
+
commands:
|
| 112 |
+
01_stop_service:
|
| 113 |
+
command: powershell -Command "C:\\'Program Files'\\Amazon\\AmazonCloudWatchAgent\\amazon-cloudwatch-agent-ctl.ps1 -a stop"
|
| 114 |
+
02_start_service:
|
| 115 |
+
command: powershell -Command "C:\\'Program Files'\\Amazon\\AmazonCloudWatchAgent\\amazon-cloudwatch-agent-ctl.ps1 -a fetch-config -m ec2 -c file:C:\\ProgramData\\Amazon\\AmazonCloudWatchAgent\\amazon-cloudwatch-agent.json -s"
|
| 116 |
+
Properties:
|
| 117 |
+
InstanceType: !Ref InstanceType
|
| 118 |
+
IamInstanceProfile: !Ref IAMRole
|
| 119 |
+
KeyName: !Ref KeyName
|
| 120 |
+
ImageId: !Ref InstanceAMI
|
| 121 |
+
SubnetId: !Ref SubnetId
|
| 122 |
+
UserData: !Base64
|
| 123 |
+
Fn::Sub: |-
|
| 124 |
+
<script>
|
| 125 |
+
mkdir C:\Downloads\Amazon\AmazonCloudWatchAgent
|
| 126 |
+
powershell -Command "(New-Object Net.WebClient).DownloadFile('https://s3.amazonaws.com/amazoncloudwatch-agent/windows/amd64/latest/amazon-cloudwatch-agent.msi','C:\Downloads\Amazon\AmazonCloudWatchAgent\amazon-cloudwatch-agent.msi')"
|
| 127 |
+
C:\Downloads\Amazon\AmazonCloudWatchAgent\amazon-cloudwatch-agent.msi
|
| 128 |
+
cfn-init.exe -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets default
|
| 129 |
+
cfn-signal.exe -e %errorlevel% --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region}
|
| 130 |
+
</script>
|
human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/ssm/amazon_linux.json
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"AWSTemplateFormatVersion": "2010-09-09",
|
| 3 |
+
"Description": "Template to install CloudWatchAgent on amazon linux. It was validated on amazon linux 2",
|
| 4 |
+
"Parameters": {
|
| 5 |
+
"SSMKey": {
|
| 6 |
+
"Description": "Name of parameter store which contains the json configuration of CWAgent.",
|
| 7 |
+
"Type": "String",
|
| 8 |
+
"Default": "AmazonCloudWatch-DefaultLinuxConfigCloudFormation"
|
| 9 |
+
},
|
| 10 |
+
"KeyName": {
|
| 11 |
+
"Description": "Name of an existing EC2 KeyPair to enable SSH access to the instance",
|
| 12 |
+
"Type": "AWS::EC2::KeyPair::KeyName",
|
| 13 |
+
"ConstraintDescription": "must be the name of an existing EC2 KeyPair."
|
| 14 |
+
},
|
| 15 |
+
"InstanceType": {
|
| 16 |
+
"Description": "EC2 instance type",
|
| 17 |
+
"Type": "String",
|
| 18 |
+
"Default": "t3.medium",
|
| 19 |
+
"ConstraintDescription": "must be a valid EC2 instance type."
|
| 20 |
+
},
|
| 21 |
+
"InstanceAMI": {
|
| 22 |
+
"Description": "Managed AMI ID for EC2 Instance",
|
| 23 |
+
"Type": "AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>",
|
| 24 |
+
"Default": "/aws/service/ami-amazon-linux-latest/al2023-ami-kernel-6.1-x86_64"
|
| 25 |
+
},
|
| 26 |
+
"IAMRole": {
|
| 27 |
+
"Description": "EC2 attached IAM role",
|
| 28 |
+
"Type": "String",
|
| 29 |
+
"Default": "CloudWatchAgentAdminRole",
|
| 30 |
+
"ConstraintDescription": "must be an existing IAM role which will be attached to EC2 instance."
|
| 31 |
+
},
|
| 32 |
+
"SSHLocation": {
|
| 33 |
+
"Description": "The IP address range that can be used to SSH to the EC2 instances",
|
| 34 |
+
"Type": "String",
|
| 35 |
+
"Default": "0.0.0.0/0",
|
| 36 |
+
"MinLength": "9",
|
| 37 |
+
"MaxLength": "18",
|
| 38 |
+
"AllowedPattern": "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})",
|
| 39 |
+
"ConstraintDescription": "must be a valid IP CIDR range of the form x.x.x.x/x."
|
| 40 |
+
},
|
| 41 |
+
"SubnetId": {
|
| 42 |
+
"Type": "AWS::EC2::Subnet::Id"
|
| 43 |
+
}
|
| 44 |
+
},
|
| 45 |
+
"Resources": {
|
| 46 |
+
"EC2Instance": {
|
| 47 |
+
"CreationPolicy": {
|
| 48 |
+
"ResourceSignal": {
|
| 49 |
+
"Count": 1,
|
| 50 |
+
"Timeout": "PT15M"
|
| 51 |
+
}
|
| 52 |
+
},
|
| 53 |
+
"Type": "AWS::EC2::Instance",
|
| 54 |
+
"Metadata": {
|
| 55 |
+
"AWS::CloudFormation::Init": {
|
| 56 |
+
"configSets": {
|
| 57 |
+
"default": [
|
| 58 |
+
"01_setupCfnHup",
|
| 59 |
+
"02_config-amazon-cloudwatch-agent",
|
| 60 |
+
"03_restart_amazon-cloudwatch-agent"
|
| 61 |
+
],
|
| 62 |
+
"UpdateEnvironment": [
|
| 63 |
+
"02_config-amazon-cloudwatch-agent",
|
| 64 |
+
"03_restart_amazon-cloudwatch-agent"
|
| 65 |
+
]
|
| 66 |
+
},
|
| 67 |
+
"02_config-amazon-cloudwatch-agent": {
|
| 68 |
+
"files": {
|
| 69 |
+
"/opt/aws/amazon-cloudwatch-agent/etc/dummy.version": {
|
| 70 |
+
"content": "\"You can change the VERSION below to to simulate the update of metadata\"\n\"VERSION=1.0\"\n"
|
| 71 |
+
}
|
| 72 |
+
}
|
| 73 |
+
},
|
| 74 |
+
"03_restart_amazon-cloudwatch-agent": {
|
| 75 |
+
"commands": {
|
| 76 |
+
"01_stop_service": {
|
| 77 |
+
"command": "/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a stop"
|
| 78 |
+
},
|
| 79 |
+
"02_start_service": {
|
| 80 |
+
"command": {
|
| 81 |
+
"Fn::Sub": [
|
| 82 |
+
"/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c ssm:${ssmkey} -s\n",
|
| 83 |
+
{
|
| 84 |
+
"ssmkey": {
|
| 85 |
+
"Ref": "SSMKey"
|
| 86 |
+
}
|
| 87 |
+
}
|
| 88 |
+
]
|
| 89 |
+
}
|
| 90 |
+
}
|
| 91 |
+
}
|
| 92 |
+
},
|
| 93 |
+
"01_setupCfnHup": {
|
| 94 |
+
"files": {
|
| 95 |
+
"/etc/cfn/cfn-hup.conf": {
|
| 96 |
+
"content": {
|
| 97 |
+
"Fn::Sub": "[main]\nstack=${AWS::StackId}\nregion=${AWS::Region}\ninterval=1\n"
|
| 98 |
+
},
|
| 99 |
+
"mode": "000400",
|
| 100 |
+
"owner": "root",
|
| 101 |
+
"group": "root"
|
| 102 |
+
},
|
| 103 |
+
"/etc/cfn/hooks.d/amazon-cloudwatch-agent-auto-reloader.conf": {
|
| 104 |
+
"content": {
|
| 105 |
+
"Fn::Sub": "[cfn-auto-reloader-hook]\ntriggers=post.update\npath=Resources.EC2Instance.Metadata.AWS::CloudFormation::Init.02_config-amazon-cloudwatch-agent\naction=/opt/aws/bin/cfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets UpdateEnvironment\nrunas=root\n"
|
| 106 |
+
},
|
| 107 |
+
"mode": "000400",
|
| 108 |
+
"owner": "root",
|
| 109 |
+
"group": "root"
|
| 110 |
+
},
|
| 111 |
+
"/lib/systemd/system/cfn-hup.service": {
|
| 112 |
+
"content": "[Unit]\nDescription=cfn-hup daemon\n[Service]\nType=simple\nExecStart=/opt/aws/bin/cfn-hup\nRestart=always\n[Install]\nWantedBy=multi-user.target\n"
|
| 113 |
+
}
|
| 114 |
+
},
|
| 115 |
+
"commands": {
|
| 116 |
+
"01enable_cfn_hup": {
|
| 117 |
+
"command": "systemctl enable cfn-hup.service"
|
| 118 |
+
},
|
| 119 |
+
"02start_cfn_hup": {
|
| 120 |
+
"command": "systemctl start cfn-hup.service"
|
| 121 |
+
}
|
| 122 |
+
}
|
| 123 |
+
}
|
| 124 |
+
}
|
| 125 |
+
},
|
| 126 |
+
"Properties": {
|
| 127 |
+
"InstanceType": {
|
| 128 |
+
"Ref": "InstanceType"
|
| 129 |
+
},
|
| 130 |
+
"IamInstanceProfile": {
|
| 131 |
+
"Ref": "IAMRole"
|
| 132 |
+
},
|
| 133 |
+
"KeyName": {
|
| 134 |
+
"Ref": "KeyName"
|
| 135 |
+
},
|
| 136 |
+
"ImageId": {
|
| 137 |
+
"Ref": "InstanceAMI"
|
| 138 |
+
},
|
| 139 |
+
"SubnetId": {
|
| 140 |
+
"Ref": "SubnetId"
|
| 141 |
+
},
|
| 142 |
+
"SecurityGroupIds": [
|
| 143 |
+
{
|
| 144 |
+
|
| 145 |
+
"Fn::GetAtt" : [ "InstanceSecurityGroup", "GroupId" ]
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
],
|
| 149 |
+
"UserData": {
|
| 150 |
+
"Fn::Base64": {
|
| 151 |
+
"Fn::Sub": [
|
| 152 |
+
"#!/bin/bash\nrpm -Uvh https://s3.amazonaws.com/amazoncloudwatch-agent/amazon_linux/amd64/latest/amazon-cloudwatch-agent.rpm\n/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c ssm:${ssmkey} -s\n/opt/aws/bin/cfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets default\n/opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region}\n",
|
| 153 |
+
{
|
| 154 |
+
"ssmkey": {
|
| 155 |
+
"Ref": "SSMKey"
|
| 156 |
+
}
|
| 157 |
+
}
|
| 158 |
+
]
|
| 159 |
+
}
|
| 160 |
+
}
|
| 161 |
+
}
|
| 162 |
+
},
|
| 163 |
+
"InstanceSecurityGroup": {
|
| 164 |
+
"Type": "AWS::EC2::SecurityGroup",
|
| 165 |
+
"Properties": {
|
| 166 |
+
"GroupDescription": "Enable SSH access via port 22",
|
| 167 |
+
"SecurityGroupIngress": [
|
| 168 |
+
{
|
| 169 |
+
"IpProtocol": "tcp",
|
| 170 |
+
"FromPort": "22",
|
| 171 |
+
"ToPort": "22",
|
| 172 |
+
"CidrIp": {
|
| 173 |
+
"Ref": "SSHLocation"
|
| 174 |
+
}
|
| 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|
|
|
|
| 1 |
+
AWSTemplateFormatVersion: "2010-09-09"
|
| 2 |
+
|
| 3 |
+
Description: Template to install CloudWatchAgent on amazon linux. It was validated on amazon linux 2
|
| 4 |
+
|
| 5 |
+
Parameters:
|
| 6 |
+
SSMKey:
|
| 7 |
+
Description: Name of parameter store which contains the json configuration of CWAgent.
|
| 8 |
+
Type: String
|
| 9 |
+
Default: AmazonCloudWatch-DefaultLinuxConfigCloudFormation
|
| 10 |
+
|
| 11 |
+
KeyName:
|
| 12 |
+
Description: Name of an existing EC2 KeyPair to enable SSH access to the instance
|
| 13 |
+
Type: AWS::EC2::KeyPair::KeyName
|
| 14 |
+
ConstraintDescription: must be the name of an existing EC2 KeyPair.
|
| 15 |
+
|
| 16 |
+
InstanceType:
|
| 17 |
+
Description: EC2 instance type
|
| 18 |
+
Type: String
|
| 19 |
+
Default: t3.medium
|
| 20 |
+
ConstraintDescription: must be a valid EC2 instance type.
|
| 21 |
+
|
| 22 |
+
InstanceAMI:
|
| 23 |
+
Description: Managed AMI ID for EC2 Instance
|
| 24 |
+
Type: AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>
|
| 25 |
+
Default: /aws/service/ami-amazon-linux-latest/al2023-ami-kernel-6.1-x86_64
|
| 26 |
+
|
| 27 |
+
IAMRole:
|
| 28 |
+
Description: EC2 attached IAM role
|
| 29 |
+
Type: String
|
| 30 |
+
Default: CloudWatchAgentAdminRole
|
| 31 |
+
ConstraintDescription: must be an existing IAM role which will be attached to EC2 instance.
|
| 32 |
+
|
| 33 |
+
SSHLocation:
|
| 34 |
+
Description: The IP address range that can be used to SSH to the EC2 instances
|
| 35 |
+
Type: String
|
| 36 |
+
Default: 0.0.0.0/0
|
| 37 |
+
MinLength: "9"
|
| 38 |
+
MaxLength: "18"
|
| 39 |
+
AllowedPattern: (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/(\d{1,2})
|
| 40 |
+
ConstraintDescription: must be a valid IP CIDR range of the form x.x.x.x/x.
|
| 41 |
+
|
| 42 |
+
SubnetId:
|
| 43 |
+
Type: AWS::EC2::Subnet::Id
|
| 44 |
+
|
| 45 |
+
Resources:
|
| 46 |
+
EC2Instance:
|
| 47 |
+
CreationPolicy:
|
| 48 |
+
ResourceSignal:
|
| 49 |
+
Count: 1
|
| 50 |
+
Timeout: PT15M
|
| 51 |
+
Type: AWS::EC2::Instance
|
| 52 |
+
Metadata:
|
| 53 |
+
AWS::CloudFormation::Init:
|
| 54 |
+
configSets:
|
| 55 |
+
default:
|
| 56 |
+
- 01_setupCfnHup
|
| 57 |
+
- 02_config-amazon-cloudwatch-agent
|
| 58 |
+
- 03_restart_amazon-cloudwatch-agent
|
| 59 |
+
UpdateEnvironment:
|
| 60 |
+
- 02_config-amazon-cloudwatch-agent
|
| 61 |
+
- 03_restart_amazon-cloudwatch-agent
|
| 62 |
+
|
| 63 |
+
# Definition of a dummy file, that change the contents of the dummy file can trigger the agent to reload the configuration from SSM parameter store.
|
| 64 |
+
02_config-amazon-cloudwatch-agent:
|
| 65 |
+
files:
|
| 66 |
+
/opt/aws/amazon-cloudwatch-agent/etc/dummy.version:
|
| 67 |
+
content: |
|
| 68 |
+
"You can change the VERSION below to to simulate the update of metadata"
|
| 69 |
+
"VERSION=1.0"
|
| 70 |
+
|
| 71 |
+
# Invoke amazon-cloudwatch-agent-ctl to restart the AmazonCloudWatchAgent.
|
| 72 |
+
03_restart_amazon-cloudwatch-agent:
|
| 73 |
+
commands:
|
| 74 |
+
01_stop_service:
|
| 75 |
+
command: /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a stop
|
| 76 |
+
02_start_service:
|
| 77 |
+
command: !Sub
|
| 78 |
+
- |
|
| 79 |
+
/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c ssm:${ssmkey} -s
|
| 80 |
+
- ssmkey: !Ref SSMKey
|
| 81 |
+
|
| 82 |
+
# Cfn-hup setting, it is to monitor the change of metadata.
|
| 83 |
+
# When there is change in the contents of json file in the metadata section, cfn-hup will call cfn-init to restart the AmazonCloudWatchAgent.
|
| 84 |
+
01_setupCfnHup:
|
| 85 |
+
files:
|
| 86 |
+
/etc/cfn/cfn-hup.conf:
|
| 87 |
+
content: !Sub |
|
| 88 |
+
[main]
|
| 89 |
+
stack=${AWS::StackId}
|
| 90 |
+
region=${AWS::Region}
|
| 91 |
+
interval=1
|
| 92 |
+
mode: "000400"
|
| 93 |
+
owner: root
|
| 94 |
+
group: root
|
| 95 |
+
/etc/cfn/hooks.d/amazon-cloudwatch-agent-auto-reloader.conf:
|
| 96 |
+
content: !Sub |
|
| 97 |
+
[cfn-auto-reloader-hook]
|
| 98 |
+
triggers=post.update
|
| 99 |
+
path=Resources.EC2Instance.Metadata.AWS::CloudFormation::Init.02_config-amazon-cloudwatch-agent
|
| 100 |
+
action=/opt/aws/bin/cfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets UpdateEnvironment
|
| 101 |
+
runas=root
|
| 102 |
+
mode: "000400"
|
| 103 |
+
owner: root
|
| 104 |
+
group: root
|
| 105 |
+
/lib/systemd/system/cfn-hup.service:
|
| 106 |
+
content: |
|
| 107 |
+
[Unit]
|
| 108 |
+
Description=cfn-hup daemon
|
| 109 |
+
[Service]
|
| 110 |
+
Type=simple
|
| 111 |
+
ExecStart=/opt/aws/bin/cfn-hup
|
| 112 |
+
Restart=always
|
| 113 |
+
[Install]
|
| 114 |
+
WantedBy=multi-user.target
|
| 115 |
+
commands:
|
| 116 |
+
01enable_cfn_hup:
|
| 117 |
+
command: systemctl enable cfn-hup.service
|
| 118 |
+
02start_cfn_hup:
|
| 119 |
+
command: systemctl start cfn-hup.service
|
| 120 |
+
Properties:
|
| 121 |
+
InstanceType: !Ref InstanceType
|
| 122 |
+
IamInstanceProfile: !Ref IAMRole
|
| 123 |
+
KeyName: !Ref KeyName
|
| 124 |
+
ImageId: !Ref InstanceAMI
|
| 125 |
+
SubnetId: !Ref SubnetId
|
| 126 |
+
SecurityGroupIds:
|
| 127 |
+
- !GetAtt InstanceSecurityGroup.GroupId
|
| 128 |
+
UserData: !Base64
|
| 129 |
+
Fn::Sub:
|
| 130 |
+
- |
|
| 131 |
+
#!/bin/bash
|
| 132 |
+
rpm -Uvh https://s3.amazonaws.com/amazoncloudwatch-agent/amazon_linux/amd64/latest/amazon-cloudwatch-agent.rpm
|
| 133 |
+
/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c ssm:${ssmkey} -s
|
| 134 |
+
/opt/aws/bin/cfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets default
|
| 135 |
+
/opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region}
|
| 136 |
+
- ssmkey: !Ref SSMKey
|
| 137 |
+
|
| 138 |
+
InstanceSecurityGroup:
|
| 139 |
+
Type: AWS::EC2::SecurityGroup
|
| 140 |
+
Properties:
|
| 141 |
+
GroupDescription: Enable SSH access via port 22
|
| 142 |
+
SecurityGroupIngress:
|
| 143 |
+
- IpProtocol: tcp
|
| 144 |
+
FromPort: "22"
|
| 145 |
+
ToPort: "22"
|
| 146 |
+
CidrIp: !Ref SSHLocation
|
human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/ssm/centos.json
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"AWSTemplateFormatVersion": "2010-09-09",
|
| 3 |
+
"Description": "Template to install CloudWatchAgent on centos. It was validated on centos 7",
|
| 4 |
+
"Parameters": {
|
| 5 |
+
"SSMKey": {
|
| 6 |
+
"Description": "Name of parameter store which contains the json configuration of CWAgent.",
|
| 7 |
+
"Type": "String",
|
| 8 |
+
"Default": "AmazonCloudWatch-DefaultLinuxConfigCloudFormation"
|
| 9 |
+
},
|
| 10 |
+
"KeyName": {
|
| 11 |
+
"Description": "Name of an existing EC2 KeyPair to enable SSH access to the instance",
|
| 12 |
+
"Type": "AWS::EC2::KeyPair::KeyName",
|
| 13 |
+
"ConstraintDescription": "must be the name of an existing EC2 KeyPair."
|
| 14 |
+
},
|
| 15 |
+
"InstanceType": {
|
| 16 |
+
"Description": "EC2 instance type",
|
| 17 |
+
"Type": "String",
|
| 18 |
+
"Default": "t3.medium",
|
| 19 |
+
"ConstraintDescription": "must be a valid EC2 instance type."
|
| 20 |
+
},
|
| 21 |
+
"CentOSVersion": {
|
| 22 |
+
"Type": "String",
|
| 23 |
+
"AllowedValues": [
|
| 24 |
+
"CentOS9"
|
| 25 |
+
],
|
| 26 |
+
"Default": "CentOS9",
|
| 27 |
+
"Description": "CentOS version to deploy"
|
| 28 |
+
},
|
| 29 |
+
"IAMRole": {
|
| 30 |
+
"Description": "EC2 attached IAM role",
|
| 31 |
+
"Type": "String",
|
| 32 |
+
"Default": "CloudWatchAgentAdminRole",
|
| 33 |
+
"ConstraintDescription": "must be an existing IAM role which will be attached to EC2 instance."
|
| 34 |
+
},
|
| 35 |
+
"SSHLocation": {
|
| 36 |
+
"Description": "The IP address range that can be used to SSH to the EC2 instances",
|
| 37 |
+
"Type": "String",
|
| 38 |
+
"Default": "0.0.0.0/0",
|
| 39 |
+
"MinLength": "9",
|
| 40 |
+
"MaxLength": "18",
|
| 41 |
+
"AllowedPattern": "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})",
|
| 42 |
+
"ConstraintDescription": "must be a valid IP CIDR range of the form x.x.x.x/x."
|
| 43 |
+
},
|
| 44 |
+
"SubnetId": {
|
| 45 |
+
"Type": "AWS::EC2::Subnet::Id"
|
| 46 |
+
}
|
| 47 |
+
},
|
| 48 |
+
"Mappings": {
|
| 49 |
+
"RegionMap": {
|
| 50 |
+
"us-east-1": {
|
| 51 |
+
"CentOS9": "ami-0705f7887207411ca"
|
| 52 |
+
},
|
| 53 |
+
"us-east-2": {
|
| 54 |
+
"CentOS9": "ami-0fe2c46c1dc3889fa"
|
| 55 |
+
},
|
| 56 |
+
"us-west-1": {
|
| 57 |
+
"CentOS9": "ami-0f4f63d1732fd4ef5"
|
| 58 |
+
},
|
| 59 |
+
"us-west-2": {
|
| 60 |
+
"CentOS9": "ami-00b231246df1d28de"
|
| 61 |
+
},
|
| 62 |
+
"eu-west-1": {
|
| 63 |
+
"CentOS9": "ami-05a7b8270231783b2"
|
| 64 |
+
},
|
| 65 |
+
"eu-west-2": {
|
| 66 |
+
"RHEL9": "ami-0086646e63ce5aaf1"
|
| 67 |
+
},
|
| 68 |
+
"ap-northeast-1": {
|
| 69 |
+
"RHEL9": "ami-0d8ee41b4b6f8343b"
|
| 70 |
+
},
|
| 71 |
+
"ap-northeast-2": {
|
| 72 |
+
"RHEL9": "ami-031e0786d2134adf6"
|
| 73 |
+
},
|
| 74 |
+
"ap-southeast-1": {
|
| 75 |
+
"RHEL9": "ami-0a9082a6b182a840b"
|
| 76 |
+
},
|
| 77 |
+
"ap-southeast-2": {
|
| 78 |
+
"RHEL9": "ami-05ffc8a6cb624035b"
|
| 79 |
+
}
|
| 80 |
+
}
|
| 81 |
+
},
|
| 82 |
+
"Resources": {
|
| 83 |
+
"EC2Instance": {
|
| 84 |
+
"CreationPolicy": {
|
| 85 |
+
"ResourceSignal": {
|
| 86 |
+
"Count": 1,
|
| 87 |
+
"Timeout": "PT15M"
|
| 88 |
+
}
|
| 89 |
+
},
|
| 90 |
+
"Type": "AWS::EC2::Instance",
|
| 91 |
+
"Metadata": {
|
| 92 |
+
"AWS::CloudFormation::Init": {
|
| 93 |
+
"configSets": {
|
| 94 |
+
"default": [
|
| 95 |
+
"01_setupCfnHup",
|
| 96 |
+
"02_config-amazon-cloudwatch-agent",
|
| 97 |
+
"03_restart_amazon-cloudwatch-agent"
|
| 98 |
+
],
|
| 99 |
+
"UpdateEnvironment": [
|
| 100 |
+
"02_config-amazon-cloudwatch-agent",
|
| 101 |
+
"03_restart_amazon-cloudwatch-agent"
|
| 102 |
+
]
|
| 103 |
+
},
|
| 104 |
+
"02_config-amazon-cloudwatch-agent": {
|
| 105 |
+
"files": {
|
| 106 |
+
"/opt/aws/amazon-cloudwatch-agent/etc/dummy.version": {
|
| 107 |
+
"content": "\"You can change the VERSION below to to simulate the update of metadata\"\n\"VERSION=1.0\"\n"
|
| 108 |
+
}
|
| 109 |
+
}
|
| 110 |
+
},
|
| 111 |
+
"03_restart_amazon-cloudwatch-agent": {
|
| 112 |
+
"commands": {
|
| 113 |
+
"01_stop_service": {
|
| 114 |
+
"command": "/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a stop"
|
| 115 |
+
},
|
| 116 |
+
"02_start_service": {
|
| 117 |
+
"command": {
|
| 118 |
+
"Fn::Sub": [
|
| 119 |
+
"/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c ssm:${ssmkey} -s\n",
|
| 120 |
+
{
|
| 121 |
+
"ssmkey": {
|
| 122 |
+
"Ref": "SSMKey"
|
| 123 |
+
}
|
| 124 |
+
}
|
| 125 |
+
]
|
| 126 |
+
}
|
| 127 |
+
}
|
| 128 |
+
}
|
| 129 |
+
},
|
| 130 |
+
"01_setupCfnHup": {
|
| 131 |
+
"files": {
|
| 132 |
+
"/etc/cfn/cfn-hup.conf": {
|
| 133 |
+
"content": {
|
| 134 |
+
"Fn::Sub": "[main]\nstack=${AWS::StackId}\nregion=${AWS::Region}\ninterval=1\n"
|
| 135 |
+
},
|
| 136 |
+
"mode": "000400",
|
| 137 |
+
"owner": "root",
|
| 138 |
+
"group": "root"
|
| 139 |
+
},
|
| 140 |
+
"/etc/cfn/hooks.d/amazon-cloudwatch-agent-auto-reloader.conf": {
|
| 141 |
+
"content": {
|
| 142 |
+
"Fn::Sub": "[cfn-auto-reloader-hook]\ntriggers=post.update\npath=Resources.EC2Instance.Metadata.AWS::CloudFormation::Init.02_config-amazon-cloudwatch-agent\naction=/opt/aws/bin/cfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets UpdateEnvironment\nrunas=root\n"
|
| 143 |
+
},
|
| 144 |
+
"mode": "000400",
|
| 145 |
+
"owner": "root",
|
| 146 |
+
"group": "root"
|
| 147 |
+
},
|
| 148 |
+
"/lib/systemd/system/cfn-hup.service": {
|
| 149 |
+
"content": "[Unit]\nDescription=cfn-hup daemon\n[Service]\nType=simple\nExecStart=/opt/aws/bin/cfn-hup\nRestart=always\n[Install]\nWantedBy=multi-user.target\n"
|
| 150 |
+
}
|
| 151 |
+
},
|
| 152 |
+
"commands": {
|
| 153 |
+
"01enable_cfn_hup": {
|
| 154 |
+
"command": "systemctl enable cfn-hup.service"
|
| 155 |
+
},
|
| 156 |
+
"02start_cfn_hup": {
|
| 157 |
+
"command": "systemctl start cfn-hup.service"
|
| 158 |
+
}
|
| 159 |
+
}
|
| 160 |
+
}
|
| 161 |
+
}
|
| 162 |
+
},
|
| 163 |
+
"Properties": {
|
| 164 |
+
"InstanceType": {
|
| 165 |
+
"Ref": "InstanceType"
|
| 166 |
+
},
|
| 167 |
+
"IamInstanceProfile": {
|
| 168 |
+
"Ref": "IAMRole"
|
| 169 |
+
},
|
| 170 |
+
"KeyName": {
|
| 171 |
+
"Ref": "KeyName"
|
| 172 |
+
},
|
| 173 |
+
"ImageId": {
|
| 174 |
+
"Fn::FindInMap": [
|
| 175 |
+
"RegionMap",
|
| 176 |
+
{
|
| 177 |
+
"Ref": "AWS::Region"
|
| 178 |
+
},
|
| 179 |
+
{
|
| 180 |
+
"Ref": "CentOSVersion"
|
| 181 |
+
}
|
| 182 |
+
]
|
| 183 |
+
},
|
| 184 |
+
"SubnetId": {
|
| 185 |
+
"Ref": "SubnetId"
|
| 186 |
+
},
|
| 187 |
+
"SecurityGroupIds": [
|
| 188 |
+
{
|
| 189 |
+
|
| 190 |
+
"Fn::GetAtt" : [ "InstanceSecurityGroup", "GroupId" ]
|
| 191 |
+
}
|
| 192 |
+
],
|
| 193 |
+
"UserData": {
|
| 194 |
+
"Fn::Base64": {
|
| 195 |
+
"Fn::Sub": [
|
| 196 |
+
"#!/bin/bash\nrpm -Uvh https://s3.amazonaws.com/amazoncloudwatch-agent/centos/amd64/latest/amazon-cloudwatch-agent.rpm\n/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c ssm:${ssmkey} -s\nyum update -y\nyum install python3 -y\ncurl -O https://bootstrap.pypa.io/get-pip.py\n# Install pip using python3\npython3 get-pip.py\nexport PATH=$PATH:/usr/local/bin\npip3 install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz\ncfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets default\ncfn-signal -e $? --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region}\n",
|
| 197 |
+
{
|
| 198 |
+
"ssmkey": {
|
| 199 |
+
"Ref": "SSMKey"
|
| 200 |
+
}
|
| 201 |
+
}
|
| 202 |
+
]
|
| 203 |
+
}
|
| 204 |
+
}
|
| 205 |
+
}
|
| 206 |
+
},
|
| 207 |
+
"InstanceSecurityGroup": {
|
| 208 |
+
"Type": "AWS::EC2::SecurityGroup",
|
| 209 |
+
"Properties": {
|
| 210 |
+
"GroupDescription": "Enable SSH access via port 22",
|
| 211 |
+
"SecurityGroupIngress": [
|
| 212 |
+
{
|
| 213 |
+
"IpProtocol": "tcp",
|
| 214 |
+
"FromPort": "22",
|
| 215 |
+
"ToPort": "22",
|
| 216 |
+
"CidrIp": {
|
| 217 |
+
"Ref": "SSHLocation"
|
| 218 |
+
}
|
| 219 |
+
}
|
| 220 |
+
]
|
| 221 |
+
}
|
| 222 |
+
}
|
| 223 |
+
}
|
| 224 |
+
}
|
human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/ssm/centos.yaml
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
AWSTemplateFormatVersion: "2010-09-09"
|
| 2 |
+
|
| 3 |
+
Description: Template to install CloudWatchAgent on centos. It was validated on centos 7
|
| 4 |
+
|
| 5 |
+
Parameters:
|
| 6 |
+
SSMKey:
|
| 7 |
+
Description: Name of parameter store which contains the json configuration of CWAgent.
|
| 8 |
+
Type: String
|
| 9 |
+
Default: AmazonCloudWatch-DefaultLinuxConfigCloudFormation
|
| 10 |
+
|
| 11 |
+
KeyName:
|
| 12 |
+
Description: Name of an existing EC2 KeyPair to enable SSH access to the instance
|
| 13 |
+
Type: AWS::EC2::KeyPair::KeyName
|
| 14 |
+
ConstraintDescription: must be the name of an existing EC2 KeyPair.
|
| 15 |
+
|
| 16 |
+
InstanceType:
|
| 17 |
+
Description: EC2 instance type
|
| 18 |
+
Type: String
|
| 19 |
+
Default: t3.medium
|
| 20 |
+
ConstraintDescription: must be a valid EC2 instance type.
|
| 21 |
+
|
| 22 |
+
CentOSVersion:
|
| 23 |
+
Type: String
|
| 24 |
+
AllowedValues:
|
| 25 |
+
- CentOS9
|
| 26 |
+
Default: CentOS9
|
| 27 |
+
Description: CentOS version to deploy
|
| 28 |
+
|
| 29 |
+
IAMRole:
|
| 30 |
+
Description: EC2 attached IAM role
|
| 31 |
+
Type: String
|
| 32 |
+
Default: CloudWatchAgentAdminRole
|
| 33 |
+
ConstraintDescription: must be an existing IAM role which will be attached to EC2 instance.
|
| 34 |
+
|
| 35 |
+
SSHLocation:
|
| 36 |
+
Description: The IP address range that can be used to SSH to the EC2 instances
|
| 37 |
+
Type: String
|
| 38 |
+
Default: 0.0.0.0/0
|
| 39 |
+
MinLength: "9"
|
| 40 |
+
MaxLength: "18"
|
| 41 |
+
AllowedPattern: (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/(\d{1,2})
|
| 42 |
+
ConstraintDescription: must be a valid IP CIDR range of the form x.x.x.x/x.
|
| 43 |
+
|
| 44 |
+
SubnetId:
|
| 45 |
+
Type: AWS::EC2::Subnet::Id
|
| 46 |
+
|
| 47 |
+
Mappings:
|
| 48 |
+
RegionMap:
|
| 49 |
+
us-east-1:
|
| 50 |
+
CentOS9: ami-0705f7887207411ca
|
| 51 |
+
us-east-2:
|
| 52 |
+
CentOS9: ami-0fe2c46c1dc3889fa
|
| 53 |
+
us-west-1:
|
| 54 |
+
CentOS9: ami-0f4f63d1732fd4ef5
|
| 55 |
+
us-west-2:
|
| 56 |
+
CentOS9: ami-00b231246df1d28de
|
| 57 |
+
eu-west-1:
|
| 58 |
+
CentOS9: ami-05a7b8270231783b2
|
| 59 |
+
eu-west-2:
|
| 60 |
+
CentOS9: ami-0086646e63ce5aaf1
|
| 61 |
+
ap-northeast-1:
|
| 62 |
+
CentOS9: ami-0d8ee41b4b6f8343b
|
| 63 |
+
ap-northeast-2:
|
| 64 |
+
CentOS9: ami-031e0786d2134adf6
|
| 65 |
+
ap-southeast-1:
|
| 66 |
+
CentOS9: ami-0a9082a6b182a840b
|
| 67 |
+
ap-southeast-2:
|
| 68 |
+
CentOS9: ami-05ffc8a6cb624035b
|
| 69 |
+
|
| 70 |
+
Resources:
|
| 71 |
+
EC2Instance:
|
| 72 |
+
CreationPolicy:
|
| 73 |
+
ResourceSignal:
|
| 74 |
+
Count: 1
|
| 75 |
+
Timeout: PT15M
|
| 76 |
+
Type: AWS::EC2::Instance
|
| 77 |
+
Metadata:
|
| 78 |
+
AWS::CloudFormation::Init:
|
| 79 |
+
configSets:
|
| 80 |
+
default:
|
| 81 |
+
- 01_setupCfnHup
|
| 82 |
+
- 02_config-amazon-cloudwatch-agent
|
| 83 |
+
- 03_restart_amazon-cloudwatch-agent
|
| 84 |
+
UpdateEnvironment:
|
| 85 |
+
- 02_config-amazon-cloudwatch-agent
|
| 86 |
+
- 03_restart_amazon-cloudwatch-agent
|
| 87 |
+
|
| 88 |
+
# Definition of a dummy file, that change the contents of the dummy file can trigger the agent to reload the configuration from SSM parameter store.
|
| 89 |
+
02_config-amazon-cloudwatch-agent:
|
| 90 |
+
files:
|
| 91 |
+
/opt/aws/amazon-cloudwatch-agent/etc/dummy.version:
|
| 92 |
+
content: |
|
| 93 |
+
"You can change the VERSION below to to simulate the update of metadata"
|
| 94 |
+
"VERSION=1.0"
|
| 95 |
+
|
| 96 |
+
# Invoke amazon-cloudwatch-agent-ctl to restart the AmazonCloudWatchAgent.
|
| 97 |
+
03_restart_amazon-cloudwatch-agent:
|
| 98 |
+
commands:
|
| 99 |
+
01_stop_service:
|
| 100 |
+
command: /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a stop
|
| 101 |
+
02_start_service:
|
| 102 |
+
command: !Sub
|
| 103 |
+
- |
|
| 104 |
+
/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c ssm:${ssmkey} -s
|
| 105 |
+
- ssmkey: !Ref SSMKey
|
| 106 |
+
|
| 107 |
+
# Cfn-hup setting, it is to monitor the change of metadata.
|
| 108 |
+
# When there is change in the contents of json file in the metadata section, cfn-hup will call cfn-init to restart the AmazonCloudWatchAgent.
|
| 109 |
+
01_setupCfnHup:
|
| 110 |
+
files:
|
| 111 |
+
/etc/cfn/cfn-hup.conf:
|
| 112 |
+
content: !Sub |
|
| 113 |
+
[main]
|
| 114 |
+
stack=${AWS::StackId}
|
| 115 |
+
region=${AWS::Region}
|
| 116 |
+
interval=1
|
| 117 |
+
mode: "000400"
|
| 118 |
+
owner: root
|
| 119 |
+
group: root
|
| 120 |
+
/etc/cfn/hooks.d/amazon-cloudwatch-agent-auto-reloader.conf:
|
| 121 |
+
content: !Sub |
|
| 122 |
+
[cfn-auto-reloader-hook]
|
| 123 |
+
triggers=post.update
|
| 124 |
+
path=Resources.EC2Instance.Metadata.AWS::CloudFormation::Init.02_config-amazon-cloudwatch-agent
|
| 125 |
+
action=/opt/aws/bin/cfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets UpdateEnvironment
|
| 126 |
+
runas=root
|
| 127 |
+
mode: "000400"
|
| 128 |
+
owner: root
|
| 129 |
+
group: root
|
| 130 |
+
/lib/systemd/system/cfn-hup.service:
|
| 131 |
+
content: |
|
| 132 |
+
[Unit]
|
| 133 |
+
Description=cfn-hup daemon
|
| 134 |
+
[Service]
|
| 135 |
+
Type=simple
|
| 136 |
+
ExecStart=/opt/aws/bin/cfn-hup
|
| 137 |
+
Restart=always
|
| 138 |
+
[Install]
|
| 139 |
+
WantedBy=multi-user.target
|
| 140 |
+
commands:
|
| 141 |
+
01enable_cfn_hup:
|
| 142 |
+
command: systemctl enable cfn-hup.service
|
| 143 |
+
02start_cfn_hup:
|
| 144 |
+
command: systemctl start cfn-hup.service
|
| 145 |
+
Properties:
|
| 146 |
+
InstanceType: !Ref InstanceType
|
| 147 |
+
IamInstanceProfile: !Ref IAMRole
|
| 148 |
+
KeyName: !Ref KeyName
|
| 149 |
+
ImageId: !FindInMap
|
| 150 |
+
- RegionMap
|
| 151 |
+
- !Ref 'AWS::Region'
|
| 152 |
+
- !Ref CentOSVersion
|
| 153 |
+
SubnetId: !Ref SubnetId
|
| 154 |
+
SecurityGroupIds:
|
| 155 |
+
- !GetAtt InstanceSecurityGroup.GroupId
|
| 156 |
+
UserData: !Base64
|
| 157 |
+
Fn::Sub:
|
| 158 |
+
- |
|
| 159 |
+
#!/bin/bash
|
| 160 |
+
rpm -Uvh https://s3.amazonaws.com/amazoncloudwatch-agent/centos/amd64/latest/amazon-cloudwatch-agent.rpm
|
| 161 |
+
/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c ssm:${ssmkey} -s
|
| 162 |
+
yum update -y
|
| 163 |
+
yum install python3 -y
|
| 164 |
+
curl -O https://bootstrap.pypa.io/get-pip.py
|
| 165 |
+
# Install pip using python3
|
| 166 |
+
python3 get-pip.py
|
| 167 |
+
export PATH=$PATH:/usr/local/bin
|
| 168 |
+
pip3 install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz
|
| 169 |
+
cfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets default
|
| 170 |
+
cfn-signal -e $? --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region}
|
| 171 |
+
- ssmkey: !Ref SSMKey
|
| 172 |
+
|
| 173 |
+
InstanceSecurityGroup:
|
| 174 |
+
Type: AWS::EC2::SecurityGroup
|
| 175 |
+
Properties:
|
| 176 |
+
GroupDescription: Enable SSH access via port 22
|
| 177 |
+
SecurityGroupIngress:
|
| 178 |
+
- IpProtocol: tcp
|
| 179 |
+
FromPort: "22"
|
| 180 |
+
ToPort: "22"
|
| 181 |
+
CidrIp: !Ref SSHLocation
|
human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/ssm/debian.json
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"AWSTemplateFormatVersion": "2010-09-09",
|
| 3 |
+
"Description": "Template to install CloudWatchAgent on debian. It was validated on debian 12.0",
|
| 4 |
+
"Parameters": {
|
| 5 |
+
"SSMKey": {
|
| 6 |
+
"Description": "Name of parameter store which contains the json configuration of CWAgent.",
|
| 7 |
+
"Type": "String",
|
| 8 |
+
"Default": "AmazonCloudWatch-DefaultLinuxConfigCloudFormation"
|
| 9 |
+
},
|
| 10 |
+
"KeyName": {
|
| 11 |
+
"Description": "Name of an existing EC2 KeyPair to enable SSH access to the instance",
|
| 12 |
+
"Type": "AWS::EC2::KeyPair::KeyName",
|
| 13 |
+
"ConstraintDescription": "must be the name of an existing EC2 KeyPair."
|
| 14 |
+
},
|
| 15 |
+
"InstanceType": {
|
| 16 |
+
"Description": "EC2 instance type",
|
| 17 |
+
"Type": "String",
|
| 18 |
+
"Default": "t3.medium",
|
| 19 |
+
"ConstraintDescription": "must be a valid EC2 instance type."
|
| 20 |
+
},
|
| 21 |
+
"InstanceAMI": {
|
| 22 |
+
"Description": "Managed AMI ID for EC2 Instance",
|
| 23 |
+
"Type": "AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>",
|
| 24 |
+
"Default": "/aws/service/debian/release/10/latest/amd64"
|
| 25 |
+
},
|
| 26 |
+
"IAMRole": {
|
| 27 |
+
"Description": "EC2 attached IAM role",
|
| 28 |
+
"Type": "String",
|
| 29 |
+
"Default": "CloudWatchAgentAdminRole",
|
| 30 |
+
"ConstraintDescription": "must be an existing IAM role which will be attached to EC2 instance."
|
| 31 |
+
},
|
| 32 |
+
"SSHLocation": {
|
| 33 |
+
"Description": "The IP address range that can be used to SSH to the EC2 instances",
|
| 34 |
+
"Type": "String",
|
| 35 |
+
"Default": "0.0.0.0/0",
|
| 36 |
+
"MinLength": "9",
|
| 37 |
+
"MaxLength": "18",
|
| 38 |
+
"AllowedPattern": "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})",
|
| 39 |
+
"ConstraintDescription": "must be a valid IP CIDR range of the form x.x.x.x/x."
|
| 40 |
+
},
|
| 41 |
+
"SubnetId": {
|
| 42 |
+
"Type": "AWS::EC2::Subnet::Id"
|
| 43 |
+
}
|
| 44 |
+
},
|
| 45 |
+
"Resources": {
|
| 46 |
+
"EC2Instance": {
|
| 47 |
+
"CreationPolicy": {
|
| 48 |
+
"ResourceSignal": {
|
| 49 |
+
"Count": 1,
|
| 50 |
+
"Timeout": "PT15M"
|
| 51 |
+
}
|
| 52 |
+
},
|
| 53 |
+
"Type": "AWS::EC2::Instance",
|
| 54 |
+
"Metadata": {
|
| 55 |
+
"AWS::CloudFormation::Init": {
|
| 56 |
+
"configSets": {
|
| 57 |
+
"default": [
|
| 58 |
+
"01_setupCfnHup",
|
| 59 |
+
"02_config-amazon-cloudwatch-agent",
|
| 60 |
+
"03_restart_amazon-cloudwatch-agent"
|
| 61 |
+
],
|
| 62 |
+
"UpdateEnvironment": [
|
| 63 |
+
"02_config-amazon-cloudwatch-agent",
|
| 64 |
+
"03_restart_amazon-cloudwatch-agent"
|
| 65 |
+
]
|
| 66 |
+
},
|
| 67 |
+
"02_config-amazon-cloudwatch-agent": {
|
| 68 |
+
"files": {
|
| 69 |
+
"/opt/aws/amazon-cloudwatch-agent/etc/dummy.version": {
|
| 70 |
+
"content": "\"You can change the VERSION below to to simulate the update of metadata\"\n\"VERSION=1.0\"\n"
|
| 71 |
+
}
|
| 72 |
+
}
|
| 73 |
+
},
|
| 74 |
+
"03_restart_amazon-cloudwatch-agent": {
|
| 75 |
+
"commands": {
|
| 76 |
+
"01_stop_service": {
|
| 77 |
+
"command": "/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a stop"
|
| 78 |
+
},
|
| 79 |
+
"02_start_service": {
|
| 80 |
+
"command": {
|
| 81 |
+
"Fn::Sub": [
|
| 82 |
+
"/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c ssm:${ssmkey} -s\n",
|
| 83 |
+
{
|
| 84 |
+
"ssmkey": {
|
| 85 |
+
"Ref": "SSMKey"
|
| 86 |
+
}
|
| 87 |
+
}
|
| 88 |
+
]
|
| 89 |
+
}
|
| 90 |
+
}
|
| 91 |
+
}
|
| 92 |
+
},
|
| 93 |
+
"01_setupCfnHup": {
|
| 94 |
+
"files": {
|
| 95 |
+
"/etc/cfn/cfn-hup.conf": {
|
| 96 |
+
"content": {
|
| 97 |
+
"Fn::Sub": "[main]\nstack=${AWS::StackId}\nregion=${AWS::Region}\ninterval=1\n"
|
| 98 |
+
},
|
| 99 |
+
"mode": "000400",
|
| 100 |
+
"owner": "root",
|
| 101 |
+
"group": "root"
|
| 102 |
+
},
|
| 103 |
+
"/etc/cfn/hooks.d/amazon-cloudwatch-agent-auto-reloader.conf": {
|
| 104 |
+
"content": {
|
| 105 |
+
"Fn::Sub": "[cfn-auto-reloader-hook]\ntriggers=post.update\npath=Resources.EC2Instance.Metadata.AWS::CloudFormation::Init.02_config-amazon-cloudwatch-agent\naction=/opt/aws/bin/cfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets UpdateEnvironment\nrunas=root\n"
|
| 106 |
+
},
|
| 107 |
+
"mode": "000400",
|
| 108 |
+
"owner": "root",
|
| 109 |
+
"group": "root"
|
| 110 |
+
},
|
| 111 |
+
"/lib/systemd/system/cfn-hup.service": {
|
| 112 |
+
"content": "[Unit]\nDescription=cfn-hup daemon\n[Service]\nType=simple\nExecStart=/opt/aws/bin/cfn-hup\nRestart=always\n[Install]\nWantedBy=multi-user.target\n"
|
| 113 |
+
}
|
| 114 |
+
},
|
| 115 |
+
"commands": {
|
| 116 |
+
"01enable_cfn_hup": {
|
| 117 |
+
"command": "systemctl enable cfn-hup.service"
|
| 118 |
+
},
|
| 119 |
+
"02start_cfn_hup": {
|
| 120 |
+
"command": "systemctl start cfn-hup.service"
|
| 121 |
+
}
|
| 122 |
+
}
|
| 123 |
+
}
|
| 124 |
+
}
|
| 125 |
+
},
|
| 126 |
+
"Properties": {
|
| 127 |
+
"InstanceType": {
|
| 128 |
+
"Ref": "InstanceType"
|
| 129 |
+
},
|
| 130 |
+
"IamInstanceProfile": {
|
| 131 |
+
"Ref": "IAMRole"
|
| 132 |
+
},
|
| 133 |
+
"KeyName": {
|
| 134 |
+
"Ref": "KeyName"
|
| 135 |
+
},
|
| 136 |
+
"ImageId": {
|
| 137 |
+
"Ref": "InstanceAMI"
|
| 138 |
+
},
|
| 139 |
+
"SubnetId": {
|
| 140 |
+
"Ref": "SubnetId"
|
| 141 |
+
},
|
| 142 |
+
"SecurityGroupIds": [
|
| 143 |
+
{
|
| 144 |
+
|
| 145 |
+
"Fn::GetAtt" : [ "InstanceSecurityGroup", "GroupId" ]
|
| 146 |
+
}
|
| 147 |
+
],
|
| 148 |
+
"UserData": {
|
| 149 |
+
"Fn::Base64": {
|
| 150 |
+
"Fn::Sub": [
|
| 151 |
+
"#!/bin/bash\nwget https://s3.amazonaws.com/amazoncloudwatch-agent/debian/amd64/latest/amazon-cloudwatch-agent.deb -O /tmp/amazon-cloudwatch-agent.deb\nsudo dpkg -i /tmp/amazon-cloudwatch-agent.deb\n/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c ssm:${ssmkey} -s\nwget https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz -O /tmp/aws-cfn-bootstrap-py3-latest.tar.gz\nsudo apt-get update -y\nsudo apt-get install -y python3-pip python3-venv\n\n# Create and activate a virtual environment\npython3 -m venv /opt/aws/virtualenv\nsource /opt/aws/virtualenv/bin/activate\n\n# Install the bootstrap package\npip install /tmp/aws-cfn-bootstrap-py3-latest.tar.gz\n\n# Create necessary symlinks\nsudo mkdir -p /opt/aws/bin\nsudo ln -s /opt/aws/virtualenv/bin/cfn-* /opt/aws/bin/\n\n# Run cfn-init\n/opt/aws/bin/cfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets default\n/opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region}\n",
|
| 152 |
+
{
|
| 153 |
+
"ssmkey": {
|
| 154 |
+
"Ref": "SSMKey"
|
| 155 |
+
}
|
| 156 |
+
}
|
| 157 |
+
]
|
| 158 |
+
}
|
| 159 |
+
}
|
| 160 |
+
}
|
| 161 |
+
},
|
| 162 |
+
"InstanceSecurityGroup": {
|
| 163 |
+
"Type": "AWS::EC2::SecurityGroup",
|
| 164 |
+
"Properties": {
|
| 165 |
+
"GroupDescription": "Enable SSH access via port 22",
|
| 166 |
+
"SecurityGroupIngress": [
|
| 167 |
+
{
|
| 168 |
+
"IpProtocol": "tcp",
|
| 169 |
+
"FromPort": "22",
|
| 170 |
+
"ToPort": "22",
|
| 171 |
+
"CidrIp": {
|
| 172 |
+
"Ref": "SSHLocation"
|
| 173 |
+
}
|
| 174 |
+
}
|
| 175 |
+
]
|
| 176 |
+
}
|
| 177 |
+
}
|
| 178 |
+
}
|
| 179 |
+
}
|
human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/ssm/debian.yaml
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
AWSTemplateFormatVersion: "2010-09-09"
|
| 2 |
+
|
| 3 |
+
Description: Template to install CloudWatchAgent on debian. It was validated on debian 12.0
|
| 4 |
+
|
| 5 |
+
Parameters:
|
| 6 |
+
SSMKey:
|
| 7 |
+
Description: Name of parameter store which contains the json configuration of CWAgent.
|
| 8 |
+
Type: String
|
| 9 |
+
Default: AmazonCloudWatch-DefaultLinuxConfigCloudFormation
|
| 10 |
+
|
| 11 |
+
KeyName:
|
| 12 |
+
Description: Name of an existing EC2 KeyPair to enable SSH access to the instance
|
| 13 |
+
Type: AWS::EC2::KeyPair::KeyName
|
| 14 |
+
ConstraintDescription: must be the name of an existing EC2 KeyPair.
|
| 15 |
+
|
| 16 |
+
InstanceType:
|
| 17 |
+
Description: EC2 instance type
|
| 18 |
+
Type: String
|
| 19 |
+
Default: t3.medium
|
| 20 |
+
ConstraintDescription: must be a valid EC2 instance type.
|
| 21 |
+
|
| 22 |
+
InstanceAMI:
|
| 23 |
+
Description: Managed AMI ID for EC2 Instance
|
| 24 |
+
Type: AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>
|
| 25 |
+
Default: /aws/service/debian/release/10/latest/amd64
|
| 26 |
+
|
| 27 |
+
IAMRole:
|
| 28 |
+
Description: EC2 attached IAM role
|
| 29 |
+
Type: String
|
| 30 |
+
Default: CloudWatchAgentAdminRole
|
| 31 |
+
ConstraintDescription: must be an existing IAM role which will be attached to EC2 instance.
|
| 32 |
+
|
| 33 |
+
SSHLocation:
|
| 34 |
+
Description: The IP address range that can be used to SSH to the EC2 instances
|
| 35 |
+
Type: String
|
| 36 |
+
Default: 0.0.0.0/0
|
| 37 |
+
MinLength: "9"
|
| 38 |
+
MaxLength: "18"
|
| 39 |
+
AllowedPattern: (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/(\d{1,2})
|
| 40 |
+
ConstraintDescription: must be a valid IP CIDR range of the form x.x.x.x/x.
|
| 41 |
+
|
| 42 |
+
SubnetId:
|
| 43 |
+
Type: AWS::EC2::Subnet::Id
|
| 44 |
+
|
| 45 |
+
Resources:
|
| 46 |
+
EC2Instance:
|
| 47 |
+
CreationPolicy:
|
| 48 |
+
ResourceSignal:
|
| 49 |
+
Count: 1
|
| 50 |
+
Timeout: PT15M
|
| 51 |
+
Type: AWS::EC2::Instance
|
| 52 |
+
Metadata:
|
| 53 |
+
AWS::CloudFormation::Init:
|
| 54 |
+
configSets:
|
| 55 |
+
default:
|
| 56 |
+
- 01_setupCfnHup
|
| 57 |
+
- 02_config-amazon-cloudwatch-agent
|
| 58 |
+
- 03_restart_amazon-cloudwatch-agent
|
| 59 |
+
UpdateEnvironment:
|
| 60 |
+
- 02_config-amazon-cloudwatch-agent
|
| 61 |
+
- 03_restart_amazon-cloudwatch-agent
|
| 62 |
+
|
| 63 |
+
# Definition of a dummy file, that change the contents of the dummy file can trigger the agent to reload the configuration from SSM parameter store.
|
| 64 |
+
02_config-amazon-cloudwatch-agent:
|
| 65 |
+
files:
|
| 66 |
+
/opt/aws/amazon-cloudwatch-agent/etc/dummy.version:
|
| 67 |
+
content: |
|
| 68 |
+
"You can change the VERSION below to to simulate the update of metadata"
|
| 69 |
+
"VERSION=1.0"
|
| 70 |
+
|
| 71 |
+
# Invoke amazon-cloudwatch-agent-ctl to restart the AmazonCloudWatchAgent.
|
| 72 |
+
03_restart_amazon-cloudwatch-agent:
|
| 73 |
+
commands:
|
| 74 |
+
01_stop_service:
|
| 75 |
+
command: /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a stop
|
| 76 |
+
02_start_service:
|
| 77 |
+
command: !Sub
|
| 78 |
+
- |
|
| 79 |
+
/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c ssm:${ssmkey} -s
|
| 80 |
+
- ssmkey: !Ref SSMKey
|
| 81 |
+
|
| 82 |
+
# Cfn-hup setting, it is to monitor the change of metadata.
|
| 83 |
+
# When there is change in the contents of json file in the metadata section, cfn-hup will call cfn-init to restart the AmazonCloudWatchAgent.
|
| 84 |
+
01_setupCfnHup:
|
| 85 |
+
files:
|
| 86 |
+
/etc/cfn/cfn-hup.conf:
|
| 87 |
+
content: !Sub |
|
| 88 |
+
[main]
|
| 89 |
+
stack=${AWS::StackId}
|
| 90 |
+
region=${AWS::Region}
|
| 91 |
+
interval=1
|
| 92 |
+
mode: "000400"
|
| 93 |
+
owner: root
|
| 94 |
+
group: root
|
| 95 |
+
/etc/cfn/hooks.d/amazon-cloudwatch-agent-auto-reloader.conf:
|
| 96 |
+
content: !Sub |
|
| 97 |
+
[cfn-auto-reloader-hook]
|
| 98 |
+
triggers=post.update
|
| 99 |
+
path=Resources.EC2Instance.Metadata.AWS::CloudFormation::Init.02_config-amazon-cloudwatch-agent
|
| 100 |
+
action=/opt/aws/bin/cfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets UpdateEnvironment
|
| 101 |
+
runas=root
|
| 102 |
+
mode: "000400"
|
| 103 |
+
owner: root
|
| 104 |
+
group: root
|
| 105 |
+
/lib/systemd/system/cfn-hup.service:
|
| 106 |
+
content: |
|
| 107 |
+
[Unit]
|
| 108 |
+
Description=cfn-hup daemon
|
| 109 |
+
[Service]
|
| 110 |
+
Type=simple
|
| 111 |
+
ExecStart=/opt/aws/bin/cfn-hup
|
| 112 |
+
Restart=always
|
| 113 |
+
[Install]
|
| 114 |
+
WantedBy=multi-user.target
|
| 115 |
+
commands:
|
| 116 |
+
01enable_cfn_hup:
|
| 117 |
+
command: systemctl enable cfn-hup.service
|
| 118 |
+
02start_cfn_hup:
|
| 119 |
+
command: systemctl start cfn-hup.service
|
| 120 |
+
Properties:
|
| 121 |
+
InstanceType: !Ref InstanceType
|
| 122 |
+
IamInstanceProfile: !Ref IAMRole
|
| 123 |
+
KeyName: !Ref KeyName
|
| 124 |
+
ImageId: !Ref InstanceAMI
|
| 125 |
+
SubnetId: !Ref SubnetId
|
| 126 |
+
SecurityGroupIds:
|
| 127 |
+
- !GetAtt InstanceSecurityGroup.GroupId
|
| 128 |
+
UserData: !Base64
|
| 129 |
+
Fn::Sub:
|
| 130 |
+
- |
|
| 131 |
+
#!/bin/bash
|
| 132 |
+
wget https://s3.amazonaws.com/amazoncloudwatch-agent/debian/amd64/latest/amazon-cloudwatch-agent.deb -O /tmp/amazon-cloudwatch-agent.deb
|
| 133 |
+
sudo dpkg -i /tmp/amazon-cloudwatch-agent.deb
|
| 134 |
+
/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c ssm:${ssmkey} -s
|
| 135 |
+
wget https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz -O /tmp/aws-cfn-bootstrap-py3-latest.tar.gz
|
| 136 |
+
sudo apt-get update -y
|
| 137 |
+
sudo apt-get install -y python3-pip python3-venv
|
| 138 |
+
|
| 139 |
+
# Create and activate a virtual environment
|
| 140 |
+
python3 -m venv /opt/aws/virtualenv
|
| 141 |
+
source /opt/aws/virtualenv/bin/activate
|
| 142 |
+
|
| 143 |
+
# Install the bootstrap package
|
| 144 |
+
pip install /tmp/aws-cfn-bootstrap-py3-latest.tar.gz
|
| 145 |
+
|
| 146 |
+
# Create necessary symlinks
|
| 147 |
+
sudo mkdir -p /opt/aws/bin
|
| 148 |
+
sudo ln -s /opt/aws/virtualenv/bin/cfn-* /opt/aws/bin/
|
| 149 |
+
|
| 150 |
+
# Run cfn-init
|
| 151 |
+
/opt/aws/bin/cfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets default
|
| 152 |
+
/opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region}
|
| 153 |
+
- ssmkey: !Ref SSMKey
|
| 154 |
+
|
| 155 |
+
InstanceSecurityGroup:
|
| 156 |
+
Type: AWS::EC2::SecurityGroup
|
| 157 |
+
Properties:
|
| 158 |
+
GroupDescription: Enable SSH access via port 22
|
| 159 |
+
SecurityGroupIngress:
|
| 160 |
+
- IpProtocol: tcp
|
| 161 |
+
FromPort: "22"
|
| 162 |
+
ToPort: "22"
|
| 163 |
+
CidrIp: !Ref SSHLocation
|
human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/ssm/redhat.json
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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 3 |
+
"Description": "Template to install CloudWatchAgent on redhat. It was validated on redhat 7.5",
|
| 4 |
+
"Parameters": {
|
| 5 |
+
"SSMKey": {
|
| 6 |
+
"Description": "Name of parameter store which contains the json configuration of CWAgent.",
|
| 7 |
+
"Type": "String",
|
| 8 |
+
"Default": "AmazonCloudWatch-DefaultLinuxConfigCloudFormation"
|
| 9 |
+
},
|
| 10 |
+
"KeyName": {
|
| 11 |
+
"Description": "Name of an existing EC2 KeyPair to enable SSH access to the instance",
|
| 12 |
+
"Type": "AWS::EC2::KeyPair::KeyName",
|
| 13 |
+
"ConstraintDescription": "must be the name of an existing EC2 KeyPair."
|
| 14 |
+
},
|
| 15 |
+
"InstanceType": {
|
| 16 |
+
"Description": "EC2 instance type",
|
| 17 |
+
"Type": "String",
|
| 18 |
+
"Default": "t3.medium",
|
| 19 |
+
"ConstraintDescription": "must be a valid EC2 instance type."
|
| 20 |
+
},
|
| 21 |
+
"RHELVersion": {
|
| 22 |
+
"Type": "String",
|
| 23 |
+
"AllowedValues": [
|
| 24 |
+
"RHEL9"
|
| 25 |
+
],
|
| 26 |
+
"Default": "RHEL9",
|
| 27 |
+
"Description": "RHEL version to deploy"
|
| 28 |
+
},
|
| 29 |
+
"IAMRole": {
|
| 30 |
+
"Description": "EC2 attached IAM role",
|
| 31 |
+
"Type": "String",
|
| 32 |
+
"Default": "CloudWatchAgentAdminRole",
|
| 33 |
+
"ConstraintDescription": "must be an existing IAM role which will be attached to EC2 instance."
|
| 34 |
+
},
|
| 35 |
+
"SSHLocation": {
|
| 36 |
+
"Description": "The IP address range that can be used to SSH to the EC2 instances",
|
| 37 |
+
"Type": "String",
|
| 38 |
+
"Default": "0.0.0.0/0",
|
| 39 |
+
"MinLength": "9",
|
| 40 |
+
"MaxLength": "18",
|
| 41 |
+
"AllowedPattern": "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})",
|
| 42 |
+
"ConstraintDescription": "must be a valid IP CIDR range of the form x.x.x.x/x."
|
| 43 |
+
},
|
| 44 |
+
"SubnetId": {
|
| 45 |
+
"Type": "AWS::EC2::Subnet::Id"
|
| 46 |
+
}
|
| 47 |
+
},
|
| 48 |
+
|
| 49 |
+
"Mappings": {
|
| 50 |
+
"RegionMap": {
|
| 51 |
+
"us-east-1": {
|
| 52 |
+
"RHEL9": "ami-0fb13bb53494158e9"
|
| 53 |
+
},
|
| 54 |
+
"us-east-2": {
|
| 55 |
+
"RHEL9": "ami-0aeea2f24f6d3ba32"
|
| 56 |
+
},
|
| 57 |
+
"us-west-1": {
|
| 58 |
+
"RHEL9": "ami-068c2af1200ef7356"
|
| 59 |
+
},
|
| 60 |
+
"us-west-2": {
|
| 61 |
+
"RHEL9": "ami-0367f2b5c3d1ef960"
|
| 62 |
+
},
|
| 63 |
+
"eu-west-1": {
|
| 64 |
+
"RHEL9": "ami-0f0f1c02e5e4d9d9f"
|
| 65 |
+
},
|
| 66 |
+
"eu-west-2": {
|
| 67 |
+
"RHEL9": "ami-02b1e3a99e36afd1a"
|
| 68 |
+
},
|
| 69 |
+
"ap-northeast-1": {
|
| 70 |
+
"RHEL9": "ami-0eade93757ef7bb6c"
|
| 71 |
+
},
|
| 72 |
+
"ap-northeast-2": {
|
| 73 |
+
"RHEL9": "ami-097698b6cd8164ea2"
|
| 74 |
+
},
|
| 75 |
+
"ap-southeast-1": {
|
| 76 |
+
"RHEL9": "ami-0b9521fddc9871128"
|
| 77 |
+
},
|
| 78 |
+
"ap-southeast-2": {
|
| 79 |
+
"RHEL9": "ami-0eea634029e7b983c"
|
| 80 |
+
}
|
| 81 |
+
}
|
| 82 |
+
},
|
| 83 |
+
|
| 84 |
+
"Resources": {
|
| 85 |
+
"EC2Instance": {
|
| 86 |
+
"CreationPolicy": {
|
| 87 |
+
"ResourceSignal": {
|
| 88 |
+
"Count": 1,
|
| 89 |
+
"Timeout": "PT15M"
|
| 90 |
+
}
|
| 91 |
+
},
|
| 92 |
+
"Type": "AWS::EC2::Instance",
|
| 93 |
+
"Metadata": {
|
| 94 |
+
"AWS::CloudFormation::Init": {
|
| 95 |
+
"configSets": {
|
| 96 |
+
"default": [
|
| 97 |
+
"01_setupCfnHup",
|
| 98 |
+
"02_config-amazon-cloudwatch-agent",
|
| 99 |
+
"03_restart_amazon-cloudwatch-agent"
|
| 100 |
+
],
|
| 101 |
+
"UpdateEnvironment": [
|
| 102 |
+
"02_config-amazon-cloudwatch-agent",
|
| 103 |
+
"03_restart_amazon-cloudwatch-agent"
|
| 104 |
+
]
|
| 105 |
+
},
|
| 106 |
+
"02_config-amazon-cloudwatch-agent": {
|
| 107 |
+
"files": {
|
| 108 |
+
"/opt/aws/amazon-cloudwatch-agent/etc/dummy.version": {
|
| 109 |
+
"content": "\"You can change the VERSION below to to simulate the update of metadata\"\n\"VERSION=1.0\"\n"
|
| 110 |
+
}
|
| 111 |
+
}
|
| 112 |
+
},
|
| 113 |
+
"03_restart_amazon-cloudwatch-agent": {
|
| 114 |
+
"commands": {
|
| 115 |
+
"01_stop_service": {
|
| 116 |
+
"command": "/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a stop"
|
| 117 |
+
},
|
| 118 |
+
"02_start_service": {
|
| 119 |
+
"command": {
|
| 120 |
+
"Fn::Sub": [
|
| 121 |
+
"/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c ssm:${ssmkey} -s\n",
|
| 122 |
+
{
|
| 123 |
+
"ssmkey": {
|
| 124 |
+
"Ref": "SSMKey"
|
| 125 |
+
}
|
| 126 |
+
}
|
| 127 |
+
]
|
| 128 |
+
}
|
| 129 |
+
}
|
| 130 |
+
}
|
| 131 |
+
},
|
| 132 |
+
"01_setupCfnHup": {
|
| 133 |
+
"files": {
|
| 134 |
+
"/etc/cfn/cfn-hup.conf": {
|
| 135 |
+
"content": {
|
| 136 |
+
"Fn::Sub": "[main]\nstack=${AWS::StackId}\nregion=${AWS::Region}\ninterval=1\n"
|
| 137 |
+
},
|
| 138 |
+
"mode": "000400",
|
| 139 |
+
"owner": "root",
|
| 140 |
+
"group": "root"
|
| 141 |
+
},
|
| 142 |
+
"/etc/cfn/hooks.d/amazon-cloudwatch-agent-auto-reloader.conf": {
|
| 143 |
+
"content": {
|
| 144 |
+
"Fn::Sub": "[cfn-auto-reloader-hook]\ntriggers=post.update\npath=Resources.EC2Instance.Metadata.AWS::CloudFormation::Init.02_config-amazon-cloudwatch-agent\naction=/opt/aws/bin/cfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets UpdateEnvironment\nrunas=root\n"
|
| 145 |
+
},
|
| 146 |
+
"mode": "000400",
|
| 147 |
+
"owner": "root",
|
| 148 |
+
"group": "root"
|
| 149 |
+
},
|
| 150 |
+
"/lib/systemd/system/cfn-hup.service": {
|
| 151 |
+
"content": "[Unit]\nDescription=cfn-hup daemon\n[Service]\nType=simple\nExecStart=/opt/aws/bin/cfn-hup\nRestart=always\n[Install]\nWantedBy=multi-user.target\n"
|
| 152 |
+
}
|
| 153 |
+
},
|
| 154 |
+
"commands": {
|
| 155 |
+
"01enable_cfn_hup": {
|
| 156 |
+
"command": "systemctl enable cfn-hup.service"
|
| 157 |
+
},
|
| 158 |
+
"02start_cfn_hup": {
|
| 159 |
+
"command": "systemctl start cfn-hup.service"
|
| 160 |
+
}
|
| 161 |
+
}
|
| 162 |
+
}
|
| 163 |
+
}
|
| 164 |
+
},
|
| 165 |
+
"Properties": {
|
| 166 |
+
"InstanceType": {
|
| 167 |
+
"Ref": "InstanceType"
|
| 168 |
+
},
|
| 169 |
+
"IamInstanceProfile": {
|
| 170 |
+
"Ref": "IAMRole"
|
| 171 |
+
},
|
| 172 |
+
"KeyName": {
|
| 173 |
+
"Ref": "KeyName"
|
| 174 |
+
},
|
| 175 |
+
"ImageId": {
|
| 176 |
+
"Fn::FindInMap": [
|
| 177 |
+
"RegionMap",
|
| 178 |
+
{
|
| 179 |
+
"Ref": "AWS::Region"
|
| 180 |
+
},
|
| 181 |
+
{
|
| 182 |
+
"Ref": "RHELVersion"
|
| 183 |
+
}
|
| 184 |
+
]
|
| 185 |
+
},
|
| 186 |
+
"SubnetId": {
|
| 187 |
+
"Ref": "SubnetId"
|
| 188 |
+
},
|
| 189 |
+
"SecurityGroupIds": [
|
| 190 |
+
{
|
| 191 |
+
|
| 192 |
+
"Fn::GetAtt" : [ "InstanceSecurityGroup", "GroupId" ]
|
| 193 |
+
}
|
| 194 |
+
],
|
| 195 |
+
"UserData": {
|
| 196 |
+
"Fn::Base64": {
|
| 197 |
+
"Fn::Sub": [
|
| 198 |
+
"#!/bin/bash\nrpm -Uvh https://s3.amazonaws.com/amazoncloudwatch-agent/redhat/amd64/latest/amazon-cloudwatch-agent.rpm\n/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c ssm:${ssmkey} -s\nyum update -y\nyum install python3 -y\ncurl -O https://bootstrap.pypa.io/get-pip.py\n# Install pip using python3\npython3 get-pip.py\nexport PATH=$PATH:/usr/local/bin\npip3 install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz\ncfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets default\ncfn-signal -e $? --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region}\n",
|
| 199 |
+
{
|
| 200 |
+
"ssmkey": {
|
| 201 |
+
"Ref": "SSMKey"
|
| 202 |
+
}
|
| 203 |
+
}
|
| 204 |
+
]
|
| 205 |
+
}
|
| 206 |
+
}
|
| 207 |
+
}
|
| 208 |
+
},
|
| 209 |
+
"InstanceSecurityGroup": {
|
| 210 |
+
"Type": "AWS::EC2::SecurityGroup",
|
| 211 |
+
"Properties": {
|
| 212 |
+
"GroupDescription": "Enable SSH access via port 22",
|
| 213 |
+
"SecurityGroupIngress": [
|
| 214 |
+
{
|
| 215 |
+
"IpProtocol": "tcp",
|
| 216 |
+
"FromPort": "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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
AWSTemplateFormatVersion: "2010-09-09"
|
| 2 |
+
|
| 3 |
+
Description: Template to install CloudWatchAgent on redhat. It was validated on redhat 7.5
|
| 4 |
+
|
| 5 |
+
Parameters:
|
| 6 |
+
SSMKey:
|
| 7 |
+
Description: Name of parameter store which contains the json configuration of CWAgent.
|
| 8 |
+
Type: String
|
| 9 |
+
Default: AmazonCloudWatch-DefaultLinuxConfigCloudFormation
|
| 10 |
+
|
| 11 |
+
KeyName:
|
| 12 |
+
Description: Name of an existing EC2 KeyPair to enable SSH access to the instance
|
| 13 |
+
Type: AWS::EC2::KeyPair::KeyName
|
| 14 |
+
ConstraintDescription: must be the name of an existing EC2 KeyPair.
|
| 15 |
+
|
| 16 |
+
InstanceType:
|
| 17 |
+
Description: EC2 instance type
|
| 18 |
+
Type: String
|
| 19 |
+
Default: t3.medium
|
| 20 |
+
ConstraintDescription: must be a valid EC2 instance type.
|
| 21 |
+
|
| 22 |
+
RHELVersion:
|
| 23 |
+
Type: String
|
| 24 |
+
AllowedValues:
|
| 25 |
+
- RHEL9
|
| 26 |
+
Default: RHEL9
|
| 27 |
+
Description: RHEL version to deploy
|
| 28 |
+
|
| 29 |
+
IAMRole:
|
| 30 |
+
Description: EC2 attached IAM role
|
| 31 |
+
Type: String
|
| 32 |
+
Default: CloudWatchAgentAdminRole
|
| 33 |
+
ConstraintDescription: must be an existing IAM role which will be attached to EC2 instance.
|
| 34 |
+
|
| 35 |
+
SSHLocation:
|
| 36 |
+
Description: The IP address range that can be used to SSH to the EC2 instances
|
| 37 |
+
Type: String
|
| 38 |
+
Default: 0.0.0.0/0
|
| 39 |
+
MinLength: "9"
|
| 40 |
+
MaxLength: "18"
|
| 41 |
+
AllowedPattern: (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/(\d{1,2})
|
| 42 |
+
ConstraintDescription: must be a valid IP CIDR range of the form x.x.x.x/x.
|
| 43 |
+
|
| 44 |
+
SubnetId:
|
| 45 |
+
Type: AWS::EC2::Subnet::Id
|
| 46 |
+
|
| 47 |
+
Mappings:
|
| 48 |
+
RegionMap:
|
| 49 |
+
us-east-1:
|
| 50 |
+
RHEL9: ami-0fb13bb53494158e9
|
| 51 |
+
us-east-2:
|
| 52 |
+
RHEL9: ami-0aeea2f24f6d3ba32
|
| 53 |
+
us-west-1:
|
| 54 |
+
RHEL9: ami-068c2af1200ef7356
|
| 55 |
+
us-west-2:
|
| 56 |
+
RHEL9: ami-0367f2b5c3d1ef960
|
| 57 |
+
eu-west-1:
|
| 58 |
+
RHEL9: ami-0e28d6c0c65e7f82f
|
| 59 |
+
eu-west-2:
|
| 60 |
+
RHEL9: ami-02b1e3a99e36afd1a
|
| 61 |
+
ap-northeast-1:
|
| 62 |
+
RHEL9: ami-0eade93757ef7bb6c
|
| 63 |
+
ap-northeast-2:
|
| 64 |
+
RHEL9: ami-097698b6cd8164ea2
|
| 65 |
+
ap-southeast-1:
|
| 66 |
+
RHEL9: ami-0b9521fddc9871128
|
| 67 |
+
ap-southeast-2:
|
| 68 |
+
RHEL9: ami-0eea634029e7b983c
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
Resources:
|
| 73 |
+
EC2Instance:
|
| 74 |
+
CreationPolicy:
|
| 75 |
+
ResourceSignal:
|
| 76 |
+
Count: 1
|
| 77 |
+
Timeout: PT15M
|
| 78 |
+
Type: AWS::EC2::Instance
|
| 79 |
+
Metadata:
|
| 80 |
+
AWS::CloudFormation::Init:
|
| 81 |
+
configSets:
|
| 82 |
+
default:
|
| 83 |
+
- 01_setupCfnHup
|
| 84 |
+
- 02_config-amazon-cloudwatch-agent
|
| 85 |
+
- 03_restart_amazon-cloudwatch-agent
|
| 86 |
+
UpdateEnvironment:
|
| 87 |
+
- 02_config-amazon-cloudwatch-agent
|
| 88 |
+
- 03_restart_amazon-cloudwatch-agent
|
| 89 |
+
|
| 90 |
+
# Definition of a dummy file, that change the contents of the dummy file can trigger the agent to reload the configuration from SSM parameter store.
|
| 91 |
+
02_config-amazon-cloudwatch-agent:
|
| 92 |
+
files:
|
| 93 |
+
/opt/aws/amazon-cloudwatch-agent/etc/dummy.version:
|
| 94 |
+
content: |
|
| 95 |
+
"You can change the VERSION below to to simulate the update of metadata"
|
| 96 |
+
"VERSION=1.0"
|
| 97 |
+
|
| 98 |
+
# Invoke amazon-cloudwatch-agent-ctl to restart the AmazonCloudWatchAgent.
|
| 99 |
+
03_restart_amazon-cloudwatch-agent:
|
| 100 |
+
commands:
|
| 101 |
+
01_stop_service:
|
| 102 |
+
command: /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a stop
|
| 103 |
+
02_start_service:
|
| 104 |
+
command: !Sub
|
| 105 |
+
- |
|
| 106 |
+
/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c ssm:${ssmkey} -s
|
| 107 |
+
- ssmkey: !Ref SSMKey
|
| 108 |
+
|
| 109 |
+
# Cfn-hup setting, it is to monitor the change of metadata.
|
| 110 |
+
# When there is change in the contents of json file in the metadata section, cfn-hup will call cfn-init to restart the AmazonCloudWatchAgent.
|
| 111 |
+
01_setupCfnHup:
|
| 112 |
+
files:
|
| 113 |
+
/etc/cfn/cfn-hup.conf:
|
| 114 |
+
content: !Sub |
|
| 115 |
+
[main]
|
| 116 |
+
stack=${AWS::StackId}
|
| 117 |
+
region=${AWS::Region}
|
| 118 |
+
interval=1
|
| 119 |
+
mode: "000400"
|
| 120 |
+
owner: root
|
| 121 |
+
group: root
|
| 122 |
+
/etc/cfn/hooks.d/amazon-cloudwatch-agent-auto-reloader.conf:
|
| 123 |
+
content: !Sub |
|
| 124 |
+
[cfn-auto-reloader-hook]
|
| 125 |
+
triggers=post.update
|
| 126 |
+
path=Resources.EC2Instance.Metadata.AWS::CloudFormation::Init.02_config-amazon-cloudwatch-agent
|
| 127 |
+
action=/opt/aws/bin/cfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets UpdateEnvironment
|
| 128 |
+
runas=root
|
| 129 |
+
mode: "000400"
|
| 130 |
+
owner: root
|
| 131 |
+
group: root
|
| 132 |
+
/lib/systemd/system/cfn-hup.service:
|
| 133 |
+
content: |
|
| 134 |
+
[Unit]
|
| 135 |
+
Description=cfn-hup daemon
|
| 136 |
+
[Service]
|
| 137 |
+
Type=simple
|
| 138 |
+
ExecStart=/opt/aws/bin/cfn-hup
|
| 139 |
+
Restart=always
|
| 140 |
+
[Install]
|
| 141 |
+
WantedBy=multi-user.target
|
| 142 |
+
commands:
|
| 143 |
+
01enable_cfn_hup:
|
| 144 |
+
command: systemctl enable cfn-hup.service
|
| 145 |
+
02start_cfn_hup:
|
| 146 |
+
command: systemctl start cfn-hup.service
|
| 147 |
+
Properties:
|
| 148 |
+
InstanceType: !Ref InstanceType
|
| 149 |
+
IamInstanceProfile: !Ref IAMRole
|
| 150 |
+
KeyName: !Ref KeyName
|
| 151 |
+
ImageId: !FindInMap
|
| 152 |
+
- RegionMap
|
| 153 |
+
- !Ref 'AWS::Region'
|
| 154 |
+
- !Ref RHELVersion
|
| 155 |
+
SubnetId: !Ref SubnetId
|
| 156 |
+
SecurityGroupIds:
|
| 157 |
+
- !GetAtt InstanceSecurityGroup.GroupId
|
| 158 |
+
UserData: !Base64
|
| 159 |
+
Fn::Sub:
|
| 160 |
+
- |
|
| 161 |
+
#!/bin/bash
|
| 162 |
+
rpm -Uvh https://s3.amazonaws.com/amazoncloudwatch-agent/redhat/amd64/latest/amazon-cloudwatch-agent.rpm
|
| 163 |
+
/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c ssm:${ssmkey} -s
|
| 164 |
+
yum update -y
|
| 165 |
+
yum install python3 -y
|
| 166 |
+
curl -O https://bootstrap.pypa.io/get-pip.py
|
| 167 |
+
# Install pip using python3
|
| 168 |
+
python3 get-pip.py
|
| 169 |
+
export PATH=$PATH:/usr/local/bin
|
| 170 |
+
pip3 install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz
|
| 171 |
+
cfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets default
|
| 172 |
+
cfn-signal -e $? --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region}
|
| 173 |
+
- ssmkey: !Ref SSMKey
|
| 174 |
+
|
| 175 |
+
InstanceSecurityGroup:
|
| 176 |
+
Type: AWS::EC2::SecurityGroup
|
| 177 |
+
Properties:
|
| 178 |
+
GroupDescription: Enable SSH access via port 22
|
| 179 |
+
SecurityGroupIngress:
|
| 180 |
+
- IpProtocol: tcp
|
| 181 |
+
FromPort: "22"
|
| 182 |
+
ToPort: "22"
|
| 183 |
+
CidrIp: !Ref SSHLocation
|
human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/ssm/suse.json
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"AWSTemplateFormatVersion": "2010-09-09",
|
| 3 |
+
"Description": "Template to install CloudWatchAgent on suse. It was validated on suse 12",
|
| 4 |
+
"Parameters": {
|
| 5 |
+
"SSMKey": {
|
| 6 |
+
"Description": "Name of parameter store which contains the json configuration of CWAgent.",
|
| 7 |
+
"Type": "String",
|
| 8 |
+
"Default": "AmazonCloudWatch-DefaultLinuxConfigCloudFormation"
|
| 9 |
+
},
|
| 10 |
+
"KeyName": {
|
| 11 |
+
"Description": "Name of an existing EC2 KeyPair to enable SSH access to the instance",
|
| 12 |
+
"Type": "AWS::EC2::KeyPair::KeyName",
|
| 13 |
+
"ConstraintDescription": "must be the name of an existing EC2 KeyPair."
|
| 14 |
+
},
|
| 15 |
+
"InstanceType": {
|
| 16 |
+
"Description": "EC2 instance type",
|
| 17 |
+
"Type": "String",
|
| 18 |
+
"Default": "t3.medium",
|
| 19 |
+
"ConstraintDescription": "must be a valid EC2 instance type."
|
| 20 |
+
},
|
| 21 |
+
"SUSEVersion": {
|
| 22 |
+
"Type": "String",
|
| 23 |
+
"AllowedValues": [
|
| 24 |
+
"SLES15SP5"
|
| 25 |
+
],
|
| 26 |
+
"Default": "SLES15SP5",
|
| 27 |
+
"Description": "SUSE Linux Enterprise Server version to deploy"
|
| 28 |
+
},
|
| 29 |
+
"IAMRole": {
|
| 30 |
+
"Description": "EC2 attached IAM role",
|
| 31 |
+
"Type": "String",
|
| 32 |
+
"Default": "CloudWatchAgentAdminRole",
|
| 33 |
+
"ConstraintDescription": "must be an existing IAM role which will be attached to EC2 instance."
|
| 34 |
+
},
|
| 35 |
+
"SSHLocation": {
|
| 36 |
+
"Description": "The IP address range that can be used to SSH to the EC2 instances",
|
| 37 |
+
"Type": "String",
|
| 38 |
+
"Default": "0.0.0.0/0",
|
| 39 |
+
"MinLength": "9",
|
| 40 |
+
"MaxLength": "18",
|
| 41 |
+
"AllowedPattern": "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})",
|
| 42 |
+
"ConstraintDescription": "must be a valid IP CIDR range of the form x.x.x.x/x."
|
| 43 |
+
},
|
| 44 |
+
"SubnetId": {
|
| 45 |
+
"Type": "AWS::EC2::Subnet::Id"
|
| 46 |
+
}
|
| 47 |
+
},
|
| 48 |
+
"Mappings": {
|
| 49 |
+
"RegionMap": {
|
| 50 |
+
"us-east-1": {
|
| 51 |
+
"SLES15SP5": "ami-0d62a8e6541a2d491"
|
| 52 |
+
},
|
| 53 |
+
"us-east-2": {
|
| 54 |
+
"SLES15SP5": "ami-05d1f1c3db2b2eb0c"
|
| 55 |
+
},
|
| 56 |
+
"us-west-1": {
|
| 57 |
+
"SLES15SP5": "ami-060034d187be82d31"
|
| 58 |
+
},
|
| 59 |
+
"us-west-2": {
|
| 60 |
+
"SLES15SP5": "ami-066c85d277ae33d38"
|
| 61 |
+
},
|
| 62 |
+
"eu-west-1": {
|
| 63 |
+
"SLES15SP5": "ami-028867095499bce4b"
|
| 64 |
+
},
|
| 65 |
+
"eu-west-2": {
|
| 66 |
+
"RHEL9": "ami-03d783398e1e54eb1"
|
| 67 |
+
},
|
| 68 |
+
"ap-northeast-1": {
|
| 69 |
+
"RHEL9": "ami-05ef8ea5a07946994"
|
| 70 |
+
},
|
| 71 |
+
"ap-northeast-2": {
|
| 72 |
+
"RHEL9": "ami-0f8bf550807d8d01a"
|
| 73 |
+
},
|
| 74 |
+
"ap-southeast-1": {
|
| 75 |
+
"RHEL9": "ami-0db03992e79210b9f"
|
| 76 |
+
},
|
| 77 |
+
"ap-southeast-2": {
|
| 78 |
+
"RHEL9": "ami-084fd76702fabcf2c"
|
| 79 |
+
}
|
| 80 |
+
}
|
| 81 |
+
},
|
| 82 |
+
"Resources": {
|
| 83 |
+
"EC2Instance": {
|
| 84 |
+
"CreationPolicy": {
|
| 85 |
+
"ResourceSignal": {
|
| 86 |
+
"Count": 1,
|
| 87 |
+
"Timeout": "PT15M"
|
| 88 |
+
}
|
| 89 |
+
},
|
| 90 |
+
"Type": "AWS::EC2::Instance",
|
| 91 |
+
"Metadata": {
|
| 92 |
+
"AWS::CloudFormation::Init": {
|
| 93 |
+
"configSets": {
|
| 94 |
+
"default": [
|
| 95 |
+
"01_setupCfnHup",
|
| 96 |
+
"02_config-amazon-cloudwatch-agent",
|
| 97 |
+
"03_restart_amazon-cloudwatch-agent"
|
| 98 |
+
],
|
| 99 |
+
"UpdateEnvironment": [
|
| 100 |
+
"02_config-amazon-cloudwatch-agent",
|
| 101 |
+
"03_restart_amazon-cloudwatch-agent"
|
| 102 |
+
]
|
| 103 |
+
},
|
| 104 |
+
"02_config-amazon-cloudwatch-agent": {
|
| 105 |
+
"files": {
|
| 106 |
+
"/opt/aws/amazon-cloudwatch-agent/etc/dummy.version": {
|
| 107 |
+
"content": "\"You can change the VERSION below to to simulate the update of metadata\"\n\"VERSION=1.0\"\n"
|
| 108 |
+
}
|
| 109 |
+
}
|
| 110 |
+
},
|
| 111 |
+
"03_restart_amazon-cloudwatch-agent": {
|
| 112 |
+
"commands": {
|
| 113 |
+
"01_stop_service": {
|
| 114 |
+
"command": "/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a stop"
|
| 115 |
+
},
|
| 116 |
+
"02_start_service": {
|
| 117 |
+
"command": {
|
| 118 |
+
"Fn::Sub": [
|
| 119 |
+
"/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c ssm:${ssmkey} -s\n",
|
| 120 |
+
{
|
| 121 |
+
"ssmkey": {
|
| 122 |
+
"Ref": "SSMKey"
|
| 123 |
+
}
|
| 124 |
+
}
|
| 125 |
+
]
|
| 126 |
+
}
|
| 127 |
+
}
|
| 128 |
+
}
|
| 129 |
+
},
|
| 130 |
+
"01_setupCfnHup": {
|
| 131 |
+
"files": {
|
| 132 |
+
"/etc/cfn/cfn-hup.conf": {
|
| 133 |
+
"content": {
|
| 134 |
+
"Fn::Sub": "[main]\nstack=${AWS::StackId}\nregion=${AWS::Region}\ninterval=1\n"
|
| 135 |
+
},
|
| 136 |
+
"mode": "000400",
|
| 137 |
+
"owner": "root",
|
| 138 |
+
"group": "root"
|
| 139 |
+
},
|
| 140 |
+
"/etc/cfn/hooks.d/amazon-cloudwatch-agent-auto-reloader.conf": {
|
| 141 |
+
"content": {
|
| 142 |
+
"Fn::Sub": "[cfn-auto-reloader-hook]\ntriggers=post.update\npath=Resources.EC2Instance.Metadata.AWS::CloudFormation::Init.02_config-amazon-cloudwatch-agent\naction=/opt/aws/bin/cfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets UpdateEnvironment\nrunas=root\n"
|
| 143 |
+
},
|
| 144 |
+
"mode": "000400",
|
| 145 |
+
"owner": "root",
|
| 146 |
+
"group": "root"
|
| 147 |
+
},
|
| 148 |
+
"/lib/systemd/system/cfn-hup.service": {
|
| 149 |
+
"content": "[Unit]\nDescription=cfn-hup daemon\n[Service]\nType=simple\nExecStart=/opt/aws/bin/cfn-hup\nRestart=always\n[Install]\nWantedBy=multi-user.target\n"
|
| 150 |
+
}
|
| 151 |
+
},
|
| 152 |
+
"commands": {
|
| 153 |
+
"01enable_cfn_hup": {
|
| 154 |
+
"command": "systemctl enable cfn-hup.service"
|
| 155 |
+
},
|
| 156 |
+
"02start_cfn_hup": {
|
| 157 |
+
"command": "systemctl start cfn-hup.service"
|
| 158 |
+
}
|
| 159 |
+
}
|
| 160 |
+
}
|
| 161 |
+
}
|
| 162 |
+
},
|
| 163 |
+
"Properties": {
|
| 164 |
+
"InstanceType": {
|
| 165 |
+
"Ref": "InstanceType"
|
| 166 |
+
},
|
| 167 |
+
"IamInstanceProfile": {
|
| 168 |
+
"Ref": "IAMRole"
|
| 169 |
+
},
|
| 170 |
+
"KeyName": {
|
| 171 |
+
"Ref": "KeyName"
|
| 172 |
+
},
|
| 173 |
+
"ImageId": {
|
| 174 |
+
"Fn::FindInMap": [
|
| 175 |
+
"RegionMap",
|
| 176 |
+
{
|
| 177 |
+
"Ref": "AWS::Region"
|
| 178 |
+
},
|
| 179 |
+
{
|
| 180 |
+
"Ref": "SUSEVersion"
|
| 181 |
+
}
|
| 182 |
+
]
|
| 183 |
+
},
|
| 184 |
+
"SubnetId": {
|
| 185 |
+
"Ref": "SubnetId"
|
| 186 |
+
},
|
| 187 |
+
"SecurityGroupIds": [
|
| 188 |
+
{
|
| 189 |
+
|
| 190 |
+
"Fn::GetAtt" : [ "InstanceSecurityGroup", "GroupId" ]
|
| 191 |
+
}
|
| 192 |
+
],
|
| 193 |
+
"UserData": {
|
| 194 |
+
"Fn::Base64": {
|
| 195 |
+
"Fn::Sub": [
|
| 196 |
+
"#!/bin/bash\nrpm -Uvh https://s3.amazonaws.com/amazoncloudwatch-agent/suse/amd64/latest/amazon-cloudwatch-agent.rpm\n/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c ssm:${ssmkey} -s\ncurl -O https://bootstrap.pypa.io/pip/3.6/get-pip.py\n# Install pip using python3\npython3 get-pip.py\nexport PATH=$PATH:/usr/local/bin\npip3 install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz\ncfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets default\ncfn-signal -e $? --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region}\n",
|
| 197 |
+
{
|
| 198 |
+
"ssmkey": {
|
| 199 |
+
"Ref": "SSMKey"
|
| 200 |
+
}
|
| 201 |
+
}
|
| 202 |
+
]
|
| 203 |
+
}
|
| 204 |
+
}
|
| 205 |
+
}
|
| 206 |
+
},
|
| 207 |
+
"InstanceSecurityGroup": {
|
| 208 |
+
"Type": "AWS::EC2::SecurityGroup",
|
| 209 |
+
"Properties": {
|
| 210 |
+
"GroupDescription": "Enable SSH access via port 22",
|
| 211 |
+
"SecurityGroupIngress": [
|
| 212 |
+
{
|
| 213 |
+
"IpProtocol": "tcp",
|
| 214 |
+
"FromPort": "22",
|
| 215 |
+
"ToPort": "22",
|
| 216 |
+
"CidrIp": {
|
| 217 |
+
"Ref": "SSHLocation"
|
| 218 |
+
}
|
| 219 |
+
}
|
| 220 |
+
]
|
| 221 |
+
}
|
| 222 |
+
}
|
| 223 |
+
}
|
| 224 |
+
}
|
human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/ssm/suse.yaml
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
AWSTemplateFormatVersion: "2010-09-09"
|
| 2 |
+
|
| 3 |
+
Description: Template to install CloudWatchAgent on suse. It was validated on suse 12
|
| 4 |
+
|
| 5 |
+
Parameters:
|
| 6 |
+
SSMKey:
|
| 7 |
+
Description: Name of parameter store which contains the json configuration of CWAgent.
|
| 8 |
+
Type: String
|
| 9 |
+
Default: AmazonCloudWatch-DefaultLinuxConfigCloudFormation
|
| 10 |
+
|
| 11 |
+
KeyName:
|
| 12 |
+
Description: Name of an existing EC2 KeyPair to enable SSH access to the instance
|
| 13 |
+
Type: AWS::EC2::KeyPair::KeyName
|
| 14 |
+
ConstraintDescription: must be the name of an existing EC2 KeyPair.
|
| 15 |
+
|
| 16 |
+
InstanceType:
|
| 17 |
+
Description: EC2 instance type
|
| 18 |
+
Type: String
|
| 19 |
+
Default: t3.medium
|
| 20 |
+
ConstraintDescription: must be a valid EC2 instance type.
|
| 21 |
+
|
| 22 |
+
SUSEVersion:
|
| 23 |
+
Type: String
|
| 24 |
+
AllowedValues:
|
| 25 |
+
- SLES15SP5
|
| 26 |
+
Default: SLES15SP5
|
| 27 |
+
Description: SUSE Linux Enterprise Server version to deploy
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
IAMRole:
|
| 31 |
+
Description: EC2 attached IAM role
|
| 32 |
+
Type: String
|
| 33 |
+
Default: CloudWatchAgentAdminRole
|
| 34 |
+
ConstraintDescription: must be an existing IAM role which will be attached to EC2 instance.
|
| 35 |
+
|
| 36 |
+
SSHLocation:
|
| 37 |
+
Description: The IP address range that can be used to SSH to the EC2 instances
|
| 38 |
+
Type: String
|
| 39 |
+
Default: 0.0.0.0/0
|
| 40 |
+
MinLength: "9"
|
| 41 |
+
MaxLength: "18"
|
| 42 |
+
AllowedPattern: (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/(\d{1,2})
|
| 43 |
+
ConstraintDescription: must be a valid IP CIDR range of the form x.x.x.x/x.
|
| 44 |
+
|
| 45 |
+
SubnetId:
|
| 46 |
+
Type: AWS::EC2::Subnet::Id
|
| 47 |
+
|
| 48 |
+
Mappings:
|
| 49 |
+
RegionMap:
|
| 50 |
+
us-east-1:
|
| 51 |
+
SLES15SP5: ami-0d62a8e6541a2d491
|
| 52 |
+
us-east-2:
|
| 53 |
+
SLES15SP5: ami-05d1f1c3db2b2eb0c
|
| 54 |
+
us-west-1:
|
| 55 |
+
SLES15SP5: ami-060034d187be82d31
|
| 56 |
+
us-west-2:
|
| 57 |
+
SLES15SP5: ami-066c85d277ae33d38
|
| 58 |
+
eu-west-1:
|
| 59 |
+
SLES15SP5: ami-028867095499bce4b
|
| 60 |
+
eu-west-2:
|
| 61 |
+
SLES15SP5: ami-03d783398e1e54eb1
|
| 62 |
+
ap-northeast-1:
|
| 63 |
+
SLES15SP5: ami-05ef8ea5a07946994
|
| 64 |
+
ap-northeast-2:
|
| 65 |
+
SLES15SP5: ami-0f8bf550807d8d01a
|
| 66 |
+
ap-southeast-1:
|
| 67 |
+
SLES15SP5: ami-0db03992e79210b9f
|
| 68 |
+
ap-southeast-2:
|
| 69 |
+
SLES15SP5: ami-084fd76702fabcf2c
|
| 70 |
+
|
| 71 |
+
Resources:
|
| 72 |
+
EC2Instance:
|
| 73 |
+
CreationPolicy:
|
| 74 |
+
ResourceSignal:
|
| 75 |
+
Count: 1
|
| 76 |
+
Timeout: PT15M
|
| 77 |
+
Type: AWS::EC2::Instance
|
| 78 |
+
Metadata:
|
| 79 |
+
AWS::CloudFormation::Init:
|
| 80 |
+
configSets:
|
| 81 |
+
default:
|
| 82 |
+
- 01_setupCfnHup
|
| 83 |
+
- 02_config-amazon-cloudwatch-agent
|
| 84 |
+
- 03_restart_amazon-cloudwatch-agent
|
| 85 |
+
UpdateEnvironment:
|
| 86 |
+
- 02_config-amazon-cloudwatch-agent
|
| 87 |
+
- 03_restart_amazon-cloudwatch-agent
|
| 88 |
+
|
| 89 |
+
# Definition of a dummy file, that change the contents of the dummy file can trigger the agent to reload the configuration from SSM parameter store.
|
| 90 |
+
02_config-amazon-cloudwatch-agent:
|
| 91 |
+
files:
|
| 92 |
+
/opt/aws/amazon-cloudwatch-agent/etc/dummy.version:
|
| 93 |
+
content: |
|
| 94 |
+
"You can change the VERSION below to to simulate the update of metadata"
|
| 95 |
+
"VERSION=1.0"
|
| 96 |
+
|
| 97 |
+
# Invoke amazon-cloudwatch-agent-ctl to restart the AmazonCloudWatchAgent.
|
| 98 |
+
03_restart_amazon-cloudwatch-agent:
|
| 99 |
+
commands:
|
| 100 |
+
01_stop_service:
|
| 101 |
+
command: /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a stop
|
| 102 |
+
02_start_service:
|
| 103 |
+
command: !Sub
|
| 104 |
+
- |
|
| 105 |
+
/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c ssm:${ssmkey} -s
|
| 106 |
+
- ssmkey: !Ref SSMKey
|
| 107 |
+
|
| 108 |
+
# Cfn-hup setting, it is to monitor the change of metadata.
|
| 109 |
+
# When there is change in the contents of json file in the metadata section, cfn-hup will call cfn-init to restart the AmazonCloudWatchAgent.
|
| 110 |
+
01_setupCfnHup:
|
| 111 |
+
files:
|
| 112 |
+
/etc/cfn/cfn-hup.conf:
|
| 113 |
+
content: !Sub |
|
| 114 |
+
[main]
|
| 115 |
+
stack=${AWS::StackId}
|
| 116 |
+
region=${AWS::Region}
|
| 117 |
+
interval=1
|
| 118 |
+
mode: "000400"
|
| 119 |
+
owner: root
|
| 120 |
+
group: root
|
| 121 |
+
/etc/cfn/hooks.d/amazon-cloudwatch-agent-auto-reloader.conf:
|
| 122 |
+
content: !Sub |
|
| 123 |
+
[cfn-auto-reloader-hook]
|
| 124 |
+
triggers=post.update
|
| 125 |
+
path=Resources.EC2Instance.Metadata.AWS::CloudFormation::Init.02_config-amazon-cloudwatch-agent
|
| 126 |
+
action=/opt/aws/bin/cfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets UpdateEnvironment
|
| 127 |
+
runas=root
|
| 128 |
+
mode: "000400"
|
| 129 |
+
owner: root
|
| 130 |
+
group: root
|
| 131 |
+
/lib/systemd/system/cfn-hup.service:
|
| 132 |
+
content: |
|
| 133 |
+
[Unit]
|
| 134 |
+
Description=cfn-hup daemon
|
| 135 |
+
[Service]
|
| 136 |
+
Type=simple
|
| 137 |
+
ExecStart=/opt/aws/bin/cfn-hup
|
| 138 |
+
Restart=always
|
| 139 |
+
[Install]
|
| 140 |
+
WantedBy=multi-user.target
|
| 141 |
+
commands:
|
| 142 |
+
01enable_cfn_hup:
|
| 143 |
+
command: systemctl enable cfn-hup.service
|
| 144 |
+
02start_cfn_hup:
|
| 145 |
+
command: systemctl start cfn-hup.service
|
| 146 |
+
Properties:
|
| 147 |
+
InstanceType: !Ref InstanceType
|
| 148 |
+
IamInstanceProfile: !Ref IAMRole
|
| 149 |
+
KeyName: !Ref KeyName
|
| 150 |
+
ImageId: !FindInMap
|
| 151 |
+
- RegionMap
|
| 152 |
+
- !Ref 'AWS::Region'
|
| 153 |
+
- !Ref SUSEVersion
|
| 154 |
+
SubnetId: !Ref SubnetId
|
| 155 |
+
SecurityGroupIds:
|
| 156 |
+
- !GetAtt InstanceSecurityGroup.GroupId
|
| 157 |
+
UserData: !Base64
|
| 158 |
+
Fn::Sub:
|
| 159 |
+
- |
|
| 160 |
+
#!/bin/bash
|
| 161 |
+
rpm -Uvh https://s3.amazonaws.com/amazoncloudwatch-agent/suse/amd64/latest/amazon-cloudwatch-agent.rpm
|
| 162 |
+
/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c ssm:${ssmkey} -s
|
| 163 |
+
curl -O https://bootstrap.pypa.io/pip/3.6/get-pip.py
|
| 164 |
+
# Install pip using python3
|
| 165 |
+
python3 get-pip.py
|
| 166 |
+
export PATH=$PATH:/usr/local/bin
|
| 167 |
+
pip3 install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz
|
| 168 |
+
cfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets default
|
| 169 |
+
cfn-signal -e $? --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region}
|
| 170 |
+
- ssmkey: !Ref SSMKey
|
| 171 |
+
|
| 172 |
+
InstanceSecurityGroup:
|
| 173 |
+
Type: AWS::EC2::SecurityGroup
|
| 174 |
+
Properties:
|
| 175 |
+
GroupDescription: Enable SSH access via port 22
|
| 176 |
+
SecurityGroupIngress:
|
| 177 |
+
- IpProtocol: tcp
|
| 178 |
+
FromPort: "22"
|
| 179 |
+
ToPort: "22"
|
| 180 |
+
CidrIp: !Ref SSHLocation
|
human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/ssm/ubuntu.json
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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ters": {
|
| 5 |
+
"SSMKey": {
|
| 6 |
+
"Description": "Name of parameter store which contains the json configuration of CWAgent.",
|
| 7 |
+
"Type": "String",
|
| 8 |
+
"Default": "AmazonCloudWatch-DefaultLinuxConfigCloudFormation"
|
| 9 |
+
},
|
| 10 |
+
"KeyName": {
|
| 11 |
+
"Description": "Name of an existing EC2 KeyPair to enable SSH access to the instance",
|
| 12 |
+
"Type": "AWS::EC2::KeyPair::KeyName",
|
| 13 |
+
"ConstraintDescription": "must be the name of an existing EC2 KeyPair."
|
| 14 |
+
},
|
| 15 |
+
"InstanceType": {
|
| 16 |
+
"Description": "EC2 instance type",
|
| 17 |
+
"Type": "String",
|
| 18 |
+
"Default": "t3.medium",
|
| 19 |
+
"ConstraintDescription": "must be a valid EC2 instance type."
|
| 20 |
+
},
|
| 21 |
+
"InstanceAMI": {
|
| 22 |
+
"Description": "Managed AMI ID for EC2 Instance",
|
| 23 |
+
"Type": "AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>",
|
| 24 |
+
"Default": "/aws/service/canonical/ubuntu/eks-pro/22.04/1.29/stable/current/amd64/hvm/ebs-gp2/ami-id"
|
| 25 |
+
},
|
| 26 |
+
"IAMRole": {
|
| 27 |
+
"Description": "EC2 attached IAM role",
|
| 28 |
+
"Type": "String",
|
| 29 |
+
"Default": "CloudWatchAgentAdminRole",
|
| 30 |
+
"ConstraintDescription": "must be an existing IAM role which will be attached to EC2 instance."
|
| 31 |
+
},
|
| 32 |
+
"SSHLocation": {
|
| 33 |
+
"Description": "The IP address range that can be used to SSH to the EC2 instances",
|
| 34 |
+
"Type": "String",
|
| 35 |
+
"Default": "0.0.0.0/0",
|
| 36 |
+
"MinLength": "9",
|
| 37 |
+
"MaxLength": "18",
|
| 38 |
+
"AllowedPattern": "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})",
|
| 39 |
+
"ConstraintDescription": "must be a valid IP CIDR range of the form x.x.x.x/x."
|
| 40 |
+
},
|
| 41 |
+
"SubnetId": {
|
| 42 |
+
"Type": "AWS::EC2::Subnet::Id"
|
| 43 |
+
}
|
| 44 |
+
},
|
| 45 |
+
"Resources": {
|
| 46 |
+
"EC2Instance": {
|
| 47 |
+
"CreationPolicy": {
|
| 48 |
+
"ResourceSignal": {
|
| 49 |
+
"Count": 1,
|
| 50 |
+
"Timeout": "PT15M"
|
| 51 |
+
}
|
| 52 |
+
},
|
| 53 |
+
"Type": "AWS::EC2::Instance",
|
| 54 |
+
"Metadata": {
|
| 55 |
+
"AWS::CloudFormation::Init": {
|
| 56 |
+
"configSets": {
|
| 57 |
+
"default": [
|
| 58 |
+
"01_setupCfnHup",
|
| 59 |
+
"02_config-amazon-cloudwatch-agent",
|
| 60 |
+
"03_restart_amazon-cloudwatch-agent"
|
| 61 |
+
],
|
| 62 |
+
"UpdateEnvironment": [
|
| 63 |
+
"02_config-amazon-cloudwatch-agent",
|
| 64 |
+
"03_restart_amazon-cloudwatch-agent"
|
| 65 |
+
]
|
| 66 |
+
},
|
| 67 |
+
"02_config-amazon-cloudwatch-agent": {
|
| 68 |
+
"files": {
|
| 69 |
+
"/opt/aws/amazon-cloudwatch-agent/etc/dummy.version": {
|
| 70 |
+
"content": "\"You can change the VERSION below to to simulate the update of metadata\"\n\"VERSION=1.0\"\n"
|
| 71 |
+
}
|
| 72 |
+
}
|
| 73 |
+
},
|
| 74 |
+
"03_restart_amazon-cloudwatch-agent": {
|
| 75 |
+
"commands": {
|
| 76 |
+
"01_stop_service": {
|
| 77 |
+
"command": "/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a stop"
|
| 78 |
+
},
|
| 79 |
+
"02_start_service": {
|
| 80 |
+
"command": {
|
| 81 |
+
"Fn::Sub": [
|
| 82 |
+
"/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c ssm:${ssmkey} -s\n",
|
| 83 |
+
{
|
| 84 |
+
"ssmkey": {
|
| 85 |
+
"Ref": "SSMKey"
|
| 86 |
+
}
|
| 87 |
+
}
|
| 88 |
+
]
|
| 89 |
+
}
|
| 90 |
+
}
|
| 91 |
+
}
|
| 92 |
+
},
|
| 93 |
+
"01_setupCfnHup": {
|
| 94 |
+
"files": {
|
| 95 |
+
"/etc/cfn/cfn-hup.conf": {
|
| 96 |
+
"content": {
|
| 97 |
+
"Fn::Sub": "[main]\nstack=${AWS::StackId}\nregion=${AWS::Region}\ninterval=1\n"
|
| 98 |
+
},
|
| 99 |
+
"mode": "000400",
|
| 100 |
+
"owner": "root",
|
| 101 |
+
"group": "root"
|
| 102 |
+
},
|
| 103 |
+
"/etc/cfn/hooks.d/amazon-cloudwatch-agent-auto-reloader.conf": {
|
| 104 |
+
"content": {
|
| 105 |
+
"Fn::Sub": "[cfn-auto-reloader-hook]\ntriggers=post.update\npath=Resources.EC2Instance.Metadata.AWS::CloudFormation::Init.02_config-amazon-cloudwatch-agent\naction=/opt/aws/bin/cfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets UpdateEnvironment\nrunas=root\n"
|
| 106 |
+
},
|
| 107 |
+
"mode": "000400",
|
| 108 |
+
"owner": "root",
|
| 109 |
+
"group": "root"
|
| 110 |
+
},
|
| 111 |
+
"/lib/systemd/system/cfn-hup.service": {
|
| 112 |
+
"content": "[Unit]\nDescription=cfn-hup daemon\n[Service]\nType=simple\nExecStart=/opt/aws/bin/cfn-hup\nRestart=always\n[Install]\nWantedBy=multi-user.target\n"
|
| 113 |
+
}
|
| 114 |
+
},
|
| 115 |
+
"commands": {
|
| 116 |
+
"01enable_cfn_hup": {
|
| 117 |
+
"command": "systemctl enable cfn-hup.service"
|
| 118 |
+
},
|
| 119 |
+
"02start_cfn_hup": {
|
| 120 |
+
"command": "systemctl start cfn-hup.service"
|
| 121 |
+
}
|
| 122 |
+
}
|
| 123 |
+
}
|
| 124 |
+
}
|
| 125 |
+
},
|
| 126 |
+
"Properties": {
|
| 127 |
+
"InstanceType": {
|
| 128 |
+
"Ref": "InstanceType"
|
| 129 |
+
},
|
| 130 |
+
"IamInstanceProfile": {
|
| 131 |
+
"Ref": "IAMRole"
|
| 132 |
+
},
|
| 133 |
+
"KeyName": {
|
| 134 |
+
"Ref": "KeyName"
|
| 135 |
+
},
|
| 136 |
+
"ImageId": {
|
| 137 |
+
"Ref": "InstanceAMI"
|
| 138 |
+
},
|
| 139 |
+
"SubnetId": {
|
| 140 |
+
"Ref": "SubnetId"
|
| 141 |
+
},
|
| 142 |
+
"SecurityGroupIds": [
|
| 143 |
+
{
|
| 144 |
+
|
| 145 |
+
"Fn::GetAtt" : [ "InstanceSecurityGroup", "GroupId" ]
|
| 146 |
+
}
|
| 147 |
+
],
|
| 148 |
+
"UserData": {
|
| 149 |
+
"Fn::Base64": {
|
| 150 |
+
"Fn::Sub": [
|
| 151 |
+
"#!/bin/bash\nwget https://s3.amazonaws.com/amazoncloudwatch-agent/ubuntu/amd64/latest/amazon-cloudwatch-agent.deb -O /tmp/amazon-cloudwatch-agent.deb\ndpkg -i /tmp/amazon-cloudwatch-agent.deb\n/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c ssm:${ssmkey} -s\napt-get update -y\napt-get install -y python3 python3-pip\npip3 install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz\ncfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets default\ncfn-signal -e $? --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region}\n",
|
| 152 |
+
{
|
| 153 |
+
"ssmkey": {
|
| 154 |
+
"Ref": "SSMKey"
|
| 155 |
+
}
|
| 156 |
+
}
|
| 157 |
+
]
|
| 158 |
+
}
|
| 159 |
+
}
|
| 160 |
+
}
|
| 161 |
+
},
|
| 162 |
+
"InstanceSecurityGroup": {
|
| 163 |
+
"Type": "AWS::EC2::SecurityGroup",
|
| 164 |
+
"Properties": {
|
| 165 |
+
"GroupDescription": "Enable SSH access via port 22",
|
| 166 |
+
"SecurityGroupIngress": [
|
| 167 |
+
{
|
| 168 |
+
"IpProtocol": "tcp",
|
| 169 |
+
"FromPort": "22",
|
| 170 |
+
"ToPort": "22",
|
| 171 |
+
"CidrIp": {
|
| 172 |
+
"Ref": "SSHLocation"
|
| 173 |
+
}
|
| 174 |
+
}
|
| 175 |
+
]
|
| 176 |
+
}
|
| 177 |
+
}
|
| 178 |
+
}
|
| 179 |
+
}
|
human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/ssm/ubuntu.yaml
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
AWSTemplateFormatVersion: "2010-09-09"
|
| 2 |
+
|
| 3 |
+
Description: Template to install CloudWatchAgent on ubuntu. It was validated on ubuntu 22.04
|
| 4 |
+
|
| 5 |
+
Parameters:
|
| 6 |
+
SSMKey:
|
| 7 |
+
Description: Name of parameter store which contains the json configuration of CWAgent.
|
| 8 |
+
Type: String
|
| 9 |
+
Default: AmazonCloudWatch-DefaultLinuxConfigCloudFormation
|
| 10 |
+
|
| 11 |
+
KeyName:
|
| 12 |
+
Description: Name of an existing EC2 KeyPair to enable SSH access to the instance
|
| 13 |
+
Type: AWS::EC2::KeyPair::KeyName
|
| 14 |
+
ConstraintDescription: must be the name of an existing EC2 KeyPair.
|
| 15 |
+
|
| 16 |
+
InstanceType:
|
| 17 |
+
Description: EC2 instance type
|
| 18 |
+
Type: String
|
| 19 |
+
Default: t3.medium
|
| 20 |
+
ConstraintDescription: must be a valid EC2 instance type.
|
| 21 |
+
|
| 22 |
+
InstanceAMI:
|
| 23 |
+
Description: Managed AMI ID for EC2 Instance
|
| 24 |
+
Type: AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>
|
| 25 |
+
Default: /aws/service/canonical/ubuntu/eks-pro/22.04/1.29/stable/current/amd64/hvm/ebs-gp2/ami-id
|
| 26 |
+
|
| 27 |
+
IAMRole:
|
| 28 |
+
Description: EC2 attached IAM role
|
| 29 |
+
Type: String
|
| 30 |
+
Default: CloudWatchAgentAdminRole
|
| 31 |
+
ConstraintDescription: must be an existing IAM role which will be attached to EC2 instance.
|
| 32 |
+
|
| 33 |
+
SSHLocation:
|
| 34 |
+
Description: The IP address range that can be used to SSH to the EC2 instances
|
| 35 |
+
Type: String
|
| 36 |
+
Default: 0.0.0.0/0
|
| 37 |
+
MinLength: "9"
|
| 38 |
+
MaxLength: "18"
|
| 39 |
+
AllowedPattern: (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/(\d{1,2})
|
| 40 |
+
ConstraintDescription: must be a valid IP CIDR range of the form x.x.x.x/x.
|
| 41 |
+
|
| 42 |
+
SubnetId:
|
| 43 |
+
Type: AWS::EC2::Subnet::Id
|
| 44 |
+
|
| 45 |
+
Resources:
|
| 46 |
+
EC2Instance:
|
| 47 |
+
CreationPolicy:
|
| 48 |
+
ResourceSignal:
|
| 49 |
+
Count: 1
|
| 50 |
+
Timeout: PT15M
|
| 51 |
+
Type: AWS::EC2::Instance
|
| 52 |
+
Metadata:
|
| 53 |
+
AWS::CloudFormation::Init:
|
| 54 |
+
configSets:
|
| 55 |
+
default:
|
| 56 |
+
- 01_setupCfnHup
|
| 57 |
+
- 02_config-amazon-cloudwatch-agent
|
| 58 |
+
- 03_restart_amazon-cloudwatch-agent
|
| 59 |
+
UpdateEnvironment:
|
| 60 |
+
- 02_config-amazon-cloudwatch-agent
|
| 61 |
+
- 03_restart_amazon-cloudwatch-agent
|
| 62 |
+
|
| 63 |
+
# Definition of a dummy file, that change the contents of the dummy file can trigger the agent to reload the configuration from SSM parameter store.
|
| 64 |
+
02_config-amazon-cloudwatch-agent:
|
| 65 |
+
files:
|
| 66 |
+
/opt/aws/amazon-cloudwatch-agent/etc/dummy.version:
|
| 67 |
+
content: |
|
| 68 |
+
"You can change the VERSION below to to simulate the update of metadata"
|
| 69 |
+
"VERSION=1.0"
|
| 70 |
+
|
| 71 |
+
# Invoke amazon-cloudwatch-agent-ctl to restart the AmazonCloudWatchAgent.
|
| 72 |
+
03_restart_amazon-cloudwatch-agent:
|
| 73 |
+
commands:
|
| 74 |
+
01_stop_service:
|
| 75 |
+
command: /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a stop
|
| 76 |
+
02_start_service:
|
| 77 |
+
command: !Sub
|
| 78 |
+
- |
|
| 79 |
+
/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c ssm:${ssmkey} -s
|
| 80 |
+
- ssmkey: !Ref SSMKey
|
| 81 |
+
|
| 82 |
+
# Cfn-hup setting, it is to monitor the change of metadata.
|
| 83 |
+
# When there is change in the contents of json file in the metadata section, cfn-hup will call cfn-init to restart the AmazonCloudWatchAgent.
|
| 84 |
+
01_setupCfnHup:
|
| 85 |
+
files:
|
| 86 |
+
/etc/cfn/cfn-hup.conf:
|
| 87 |
+
content: !Sub |
|
| 88 |
+
[main]
|
| 89 |
+
stack=${AWS::StackId}
|
| 90 |
+
region=${AWS::Region}
|
| 91 |
+
interval=1
|
| 92 |
+
mode: "000400"
|
| 93 |
+
owner: root
|
| 94 |
+
group: root
|
| 95 |
+
/etc/cfn/hooks.d/amazon-cloudwatch-agent-auto-reloader.conf:
|
| 96 |
+
content: !Sub |
|
| 97 |
+
[cfn-auto-reloader-hook]
|
| 98 |
+
triggers=post.update
|
| 99 |
+
path=Resources.EC2Instance.Metadata.AWS::CloudFormation::Init.02_config-amazon-cloudwatch-agent
|
| 100 |
+
action=/opt/aws/bin/cfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets UpdateEnvironment
|
| 101 |
+
runas=root
|
| 102 |
+
mode: "000400"
|
| 103 |
+
owner: root
|
| 104 |
+
group: root
|
| 105 |
+
/lib/systemd/system/cfn-hup.service:
|
| 106 |
+
content: |
|
| 107 |
+
[Unit]
|
| 108 |
+
Description=cfn-hup daemon
|
| 109 |
+
[Service]
|
| 110 |
+
Type=simple
|
| 111 |
+
ExecStart=/opt/aws/bin/cfn-hup
|
| 112 |
+
Restart=always
|
| 113 |
+
[Install]
|
| 114 |
+
WantedBy=multi-user.target
|
| 115 |
+
commands:
|
| 116 |
+
01enable_cfn_hup:
|
| 117 |
+
command: systemctl enable cfn-hup.service
|
| 118 |
+
02start_cfn_hup:
|
| 119 |
+
command: systemctl start cfn-hup.service
|
| 120 |
+
Properties:
|
| 121 |
+
InstanceType: !Ref InstanceType
|
| 122 |
+
IamInstanceProfile: !Ref IAMRole
|
| 123 |
+
KeyName: !Ref KeyName
|
| 124 |
+
ImageId: !Ref InstanceAMI
|
| 125 |
+
SubnetId: !Ref SubnetId
|
| 126 |
+
SecurityGroupIds:
|
| 127 |
+
- !GetAtt InstanceSecurityGroup.GroupId
|
| 128 |
+
UserData: !Base64
|
| 129 |
+
Fn::Sub:
|
| 130 |
+
- |
|
| 131 |
+
#!/bin/bash
|
| 132 |
+
wget https://s3.amazonaws.com/amazoncloudwatch-agent/ubuntu/amd64/latest/amazon-cloudwatch-agent.deb -O /tmp/amazon-cloudwatch-agent.deb
|
| 133 |
+
dpkg -i /tmp/amazon-cloudwatch-agent.deb
|
| 134 |
+
/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c ssm:${ssmkey} -s
|
| 135 |
+
apt-get update -y
|
| 136 |
+
apt-get install -y python3 python3-pip
|
| 137 |
+
pip3 install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz
|
| 138 |
+
cfn-init -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets default
|
| 139 |
+
cfn-signal -e $? --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region}
|
| 140 |
+
- ssmkey: !Ref SSMKey
|
| 141 |
+
|
| 142 |
+
InstanceSecurityGroup:
|
| 143 |
+
Type: AWS::EC2::SecurityGroup
|
| 144 |
+
Properties:
|
| 145 |
+
GroupDescription: Enable SSH access via port 22
|
| 146 |
+
SecurityGroupIngress:
|
| 147 |
+
- IpProtocol: tcp
|
| 148 |
+
FromPort: "22"
|
| 149 |
+
ToPort: "22"
|
| 150 |
+
CidrI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
"Description": "Template to install CloudWatchAgent on windows. It was validated on windows 2016",
|
| 4 |
+
"Parameters": {
|
| 5 |
+
"SSMKey": {
|
| 6 |
+
"Description": "Name of parameter store which contains the json configuration of CWAgent.",
|
| 7 |
+
"Type": "String",
|
| 8 |
+
"Default": "AmazonCloudWatch-DefaultWindowsConfigCloudFormation"
|
| 9 |
+
},
|
| 10 |
+
"KeyName": {
|
| 11 |
+
"Description": "Name of an existing EC2 KeyPair to enable SSH access to the instance",
|
| 12 |
+
"Type": "AWS::EC2::KeyPair::KeyName",
|
| 13 |
+
"ConstraintDescription": "must be the name of an existing EC2 KeyPair."
|
| 14 |
+
},
|
| 15 |
+
"InstanceType": {
|
| 16 |
+
"Description": "EC2 instance type",
|
| 17 |
+
"Type": "String",
|
| 18 |
+
"Default": "t3.medium",
|
| 19 |
+
"ConstraintDescription": "must be a valid EC2 instance type."
|
| 20 |
+
},
|
| 21 |
+
"InstanceAMI": {
|
| 22 |
+
"Description": "Managed AMI ID for EC2 Instance",
|
| 23 |
+
"Type": "AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>",
|
| 24 |
+
"Default": "/aws/service/ami-windows-latest/Windows_Server-2022-English-Full-SQL_2022_Web"
|
| 25 |
+
},
|
| 26 |
+
"IAMRole": {
|
| 27 |
+
"Description": "EC2 attached IAM role",
|
| 28 |
+
"Type": "String",
|
| 29 |
+
"Default": "CloudWatchAgentAdminRole",
|
| 30 |
+
"ConstraintDescription": "must be an existing IAM role which will be attached to EC2 instance."
|
| 31 |
+
},
|
| 32 |
+
"SubnetId": {
|
| 33 |
+
"Type": "AWS::EC2::Subnet::Id"
|
| 34 |
+
}
|
| 35 |
+
},
|
| 36 |
+
"Resources": {
|
| 37 |
+
"EC2Instance": {
|
| 38 |
+
"CreationPolicy": {
|
| 39 |
+
"ResourceSignal": {
|
| 40 |
+
"Count": 1,
|
| 41 |
+
"Timeout": "PT15M"
|
| 42 |
+
}
|
| 43 |
+
},
|
| 44 |
+
"Type": "AWS::EC2::Instance",
|
| 45 |
+
"Metadata": {
|
| 46 |
+
"AWS::CloudFormation::Init": {
|
| 47 |
+
"configSets": {
|
| 48 |
+
"default": [
|
| 49 |
+
"00_setupCfnHup",
|
| 50 |
+
"01_CfnHup_service",
|
| 51 |
+
"02_config-amazon-cloudwatch-agent",
|
| 52 |
+
"03_restart_amazon-cloudwatch-agent"
|
| 53 |
+
],
|
| 54 |
+
"UpdateEnvironment": [
|
| 55 |
+
"02_config-amazon-cloudwatch-agent",
|
| 56 |
+
"03_restart_amazon-cloudwatch-agent"
|
| 57 |
+
]
|
| 58 |
+
},
|
| 59 |
+
"00_setupCfnHup": {
|
| 60 |
+
"files": {
|
| 61 |
+
"c:\\cfn\\cfn-hup.conf": {
|
| 62 |
+
"content": {
|
| 63 |
+
"Fn::Sub": "[main]\nstack=${AWS::StackId}\nregion=${AWS::Region}\ninterval=1\n"
|
| 64 |
+
}
|
| 65 |
+
},
|
| 66 |
+
"c:\\cfn\\hooks.d\\amazon-cloudwatch-agent-auto-reloader.conf": {
|
| 67 |
+
"content": {
|
| 68 |
+
"Fn::Sub": "[cfn-auto-reloader-hook]\ntriggers=post.update\npath=Resources.EC2Instance.Metadata.AWS::CloudFormation::Init.02_config-amazon-cloudwatch-agent\naction=cfn-init.exe -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets UpdateEnvironment\n"
|
| 69 |
+
}
|
| 70 |
+
}
|
| 71 |
+
}
|
| 72 |
+
},
|
| 73 |
+
"01_CfnHup_service": {
|
| 74 |
+
"services": {
|
| 75 |
+
"windows": {
|
| 76 |
+
"cfn-hup": {
|
| 77 |
+
"enabled": "true",
|
| 78 |
+
"ensureRunning": "true",
|
| 79 |
+
"files": [
|
| 80 |
+
"c:\\cfn\\cfn-hup.conf",
|
| 81 |
+
"c:\\cfn\\hooks.d\\cfn-auto-reloader.conf"
|
| 82 |
+
]
|
| 83 |
+
}
|
| 84 |
+
}
|
| 85 |
+
}
|
| 86 |
+
},
|
| 87 |
+
"02_config-amazon-cloudwatch-agent": {
|
| 88 |
+
"files": {
|
| 89 |
+
"C:\\ProgramData\\Amazon\\AmazonCloudWatchAgent\\dummy.version": {
|
| 90 |
+
"content": "\"You can change the VERSION below to to simulate the update of metadata\"\n\"VERSION=1.0\"\n"
|
| 91 |
+
}
|
| 92 |
+
}
|
| 93 |
+
},
|
| 94 |
+
"03_restart_amazon-cloudwatch-agent": {
|
| 95 |
+
"commands": {
|
| 96 |
+
"01_stop_service": {
|
| 97 |
+
"command": "powershell -Command \"C:\\\\'Program Files'\\\\Amazon\\\\AmazonCloudWatchAgent\\\\amazon-cloudwatch-agent-ctl.ps1 -a stop\""
|
| 98 |
+
},
|
| 99 |
+
"02_start_service": {
|
| 100 |
+
"command": {
|
| 101 |
+
"Fn::Sub": [
|
| 102 |
+
"powershell -Command \"C:\\\\'Program Files'\\\\Amazon\\\\AmazonCloudWatchAgent\\\\amazon-cloudwatch-agent-ctl.ps1 -a fetch-config -m ec2 -c ssm:${ssmkey} -s\"\n",
|
| 103 |
+
{
|
| 104 |
+
"ssmkey": {
|
| 105 |
+
"Ref": "SSMKey"
|
| 106 |
+
}
|
| 107 |
+
}
|
| 108 |
+
]
|
| 109 |
+
}
|
| 110 |
+
}
|
| 111 |
+
}
|
| 112 |
+
}
|
| 113 |
+
}
|
| 114 |
+
},
|
| 115 |
+
"Properties": {
|
| 116 |
+
"InstanceType": {
|
| 117 |
+
"Ref": "InstanceType"
|
| 118 |
+
},
|
| 119 |
+
"IamInstanceProfile": {
|
| 120 |
+
"Ref": "IAMRole"
|
| 121 |
+
},
|
| 122 |
+
"KeyName": {
|
| 123 |
+
"Ref": "KeyName"
|
| 124 |
+
},
|
| 125 |
+
"ImageId": {
|
| 126 |
+
"Ref": "InstanceAMI"
|
| 127 |
+
},
|
| 128 |
+
"SubnetId": {
|
| 129 |
+
"Ref": "SubnetId"
|
| 130 |
+
},
|
| 131 |
+
"UserData": {
|
| 132 |
+
"Fn::Base64": {
|
| 133 |
+
"Fn::Sub": [
|
| 134 |
+
"<script>\nmkdir C:\\Downloads\\Amazon\\AmazonCloudWatchAgent\npowershell -Command \"(New-Object Net.WebClient).DownloadFile('https://s3.amazonaws.com/amazoncloudwatch-agent/windows/amd64/latest/amazon-cloudwatch-agent.msi','C:\\Downloads\\Amazon\\AmazonCloudWatchAgent\\amazon-cloudwatch-agent.msi')\"\nC:\\Downloads\\Amazon\\AmazonCloudWatchAgent\\amazon-cloudwatch-agent.msi\npowershell -Command \"C:\\'Program Files'\\Amazon\\AmazonCloudWatchAgent\\amazon-cloudwatch-agent-ctl.ps1 -a fetch-config -m ec2 -c ssm:${ssmkey} -s\"\ncfn-init.exe -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets default\ncfn-signal.exe -e %errorlevel% --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region}\n </script>\n",
|
| 135 |
+
{
|
| 136 |
+
"ssmkey": {
|
| 137 |
+
"Ref": "SSMKey"
|
| 138 |
+
}
|
| 139 |
+
}
|
| 140 |
+
]
|
| 141 |
+
}
|
| 142 |
+
}
|
| 143 |
+
}
|
| 144 |
+
}
|
| 145 |
+
}
|
| 146 |
+
}
|
human_reference_dataset/aws-cloudformation-templates/Solutions/AmazonCloudWatchAgent/ssm/windows.yaml
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
AWSTemplateFormatVersion: "2010-09-09"
|
| 2 |
+
|
| 3 |
+
Description: Template to install CloudWatchAgent on windows. It was validated on windows 2016
|
| 4 |
+
|
| 5 |
+
Parameters:
|
| 6 |
+
SSMKey:
|
| 7 |
+
Description: Name of parameter store which contains the json configuration of CWAgent.
|
| 8 |
+
Type: String
|
| 9 |
+
Default: AmazonCloudWatch-DefaultWindowsConfigCloudFormation
|
| 10 |
+
|
| 11 |
+
KeyName:
|
| 12 |
+
Description: Name of an existing EC2 KeyPair to enable SSH access to the instance
|
| 13 |
+
Type: AWS::EC2::KeyPair::KeyName
|
| 14 |
+
ConstraintDescription: must be the name of an existing EC2 KeyPair.
|
| 15 |
+
|
| 16 |
+
InstanceType:
|
| 17 |
+
Description: EC2 instance type
|
| 18 |
+
Type: String
|
| 19 |
+
Default: t3.medium
|
| 20 |
+
ConstraintDescription: must be a valid EC2 instance type.
|
| 21 |
+
|
| 22 |
+
InstanceAMI:
|
| 23 |
+
Description: Managed AMI ID for EC2 Instance
|
| 24 |
+
Type: AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>
|
| 25 |
+
Default: /aws/service/ami-windows-latest/Windows_Server-2022-English-Full-SQL_2022_Web
|
| 26 |
+
|
| 27 |
+
IAMRole:
|
| 28 |
+
Description: EC2 attached IAM role
|
| 29 |
+
Type: String
|
| 30 |
+
Default: CloudWatchAgentAdminRole
|
| 31 |
+
ConstraintDescription: must be an existing IAM role which will be attached to EC2 instance.
|
| 32 |
+
|
| 33 |
+
SubnetId:
|
| 34 |
+
Type: AWS::EC2::Subnet::Id
|
| 35 |
+
|
| 36 |
+
Resources:
|
| 37 |
+
EC2Instance:
|
| 38 |
+
CreationPolicy:
|
| 39 |
+
ResourceSignal:
|
| 40 |
+
Count: 1
|
| 41 |
+
Timeout: PT15M
|
| 42 |
+
Type: AWS::EC2::Instance
|
| 43 |
+
Metadata:
|
| 44 |
+
AWS::CloudFormation::Init:
|
| 45 |
+
configSets:
|
| 46 |
+
default:
|
| 47 |
+
- 00_setupCfnHup
|
| 48 |
+
- 01_CfnHup_service
|
| 49 |
+
- 02_config-amazon-cloudwatch-agent
|
| 50 |
+
- 03_restart_amazon-cloudwatch-agent
|
| 51 |
+
UpdateEnvironment:
|
| 52 |
+
- 02_config-amazon-cloudwatch-agent
|
| 53 |
+
- 03_restart_amazon-cloudwatch-agent
|
| 54 |
+
|
| 55 |
+
# Cfn-hup setting, it is to monitor the change of metadata.
|
| 56 |
+
# When there is change in the contents of json file in the metadata section, cfn-hup will call cfn-init to restart the AmazonCloudWatchAgent.
|
| 57 |
+
00_setupCfnHup:
|
| 58 |
+
files:
|
| 59 |
+
c:\cfn\cfn-hup.conf:
|
| 60 |
+
content: !Sub |
|
| 61 |
+
[main]
|
| 62 |
+
stack=${AWS::StackId}
|
| 63 |
+
region=${AWS::Region}
|
| 64 |
+
interval=1
|
| 65 |
+
c:\cfn\hooks.d\amazon-cloudwatch-agent-auto-reloader.conf:
|
| 66 |
+
content: !Sub |
|
| 67 |
+
[cfn-auto-reloader-hook]
|
| 68 |
+
triggers=post.update
|
| 69 |
+
path=Resources.EC2Instance.Metadata.AWS::CloudFormation::Init.02_config-amazon-cloudwatch-agent
|
| 70 |
+
action=cfn-init.exe -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets UpdateEnvironment
|
| 71 |
+
01_CfnHup_service:
|
| 72 |
+
services:
|
| 73 |
+
windows:
|
| 74 |
+
cfn-hup:
|
| 75 |
+
enabled: "true"
|
| 76 |
+
ensureRunning: "true"
|
| 77 |
+
files:
|
| 78 |
+
- c:\cfn\cfn-hup.conf
|
| 79 |
+
- c:\cfn\hooks.d\cfn-auto-reloader.conf
|
| 80 |
+
|
| 81 |
+
# Definition of a dummy file, that change the contents of the dummy file can trigger the agent to reload the configuration from SSM parameter store.
|
| 82 |
+
02_config-amazon-cloudwatch-agent:
|
| 83 |
+
files:
|
| 84 |
+
C:\ProgramData\Amazon\AmazonCloudWatchAgent\dummy.version:
|
| 85 |
+
content: |
|
| 86 |
+
"You can change the VERSION below to to simulate the update of metadata"
|
| 87 |
+
"VERSION=1.0"
|
| 88 |
+
|
| 89 |
+
# Invoke amazon-cloudwatch-agent-ctl to restart the AmazonCloudWatchAgent.
|
| 90 |
+
03_restart_amazon-cloudwatch-agent:
|
| 91 |
+
commands:
|
| 92 |
+
01_stop_service:
|
| 93 |
+
command: powershell -Command "C:\\'Program Files'\\Amazon\\AmazonCloudWatchAgent\\amazon-cloudwatch-agent-ctl.ps1 -a stop"
|
| 94 |
+
02_start_service:
|
| 95 |
+
command: !Sub
|
| 96 |
+
- |
|
| 97 |
+
powershell -Command "C:\\'Program Files'\\Amazon\\AmazonCloudWatchAgent\\amazon-cloudwatch-agent-ctl.ps1 -a fetch-config -m ec2 -c ssm:${ssmkey} -s"
|
| 98 |
+
- ssmkey: !Ref SSMKey
|
| 99 |
+
Properties:
|
| 100 |
+
InstanceType: !Ref InstanceType
|
| 101 |
+
IamInstanceProfile: !Ref IAMRole
|
| 102 |
+
KeyName: !Ref KeyName
|
| 103 |
+
ImageId: !Ref InstanceAMI
|
| 104 |
+
SubnetId: !Ref SubnetId
|
| 105 |
+
UserData: !Base64
|
| 106 |
+
Fn::Sub:
|
| 107 |
+
- |
|
| 108 |
+
<script>
|
| 109 |
+
mkdir C:\Downloads\Amazon\AmazonCloudWatchAgent
|
| 110 |
+
powershell -Command "(New-Object Net.WebClient).DownloadFile('https://s3.amazonaws.com/amazoncloudwatch-agent/windows/amd64/latest/amazon-cloudwatch-agent.msi','C:\Downloads\Amazon\AmazonCloudWatchAgent\amazon-cloudwatch-agent.msi')"
|
| 111 |
+
C:\Downloads\Amazon\AmazonCloudWatchAgent\amazon-cloudwatch-agent.msi
|
| 112 |
+
powershell -Command "C:\'Program Files'\Amazon\AmazonCloudWatchAgent\amazon-cloudwatch-agent-ctl.ps1 -a fetch-config -m ec2 -c ssm:${ssmkey} -s"
|
| 113 |
+
cfn-init.exe -v --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region} --configsets default
|
| 114 |
+
cfn-signal.exe -e %errorlevel% --stack ${AWS::StackId} --resource EC2Instance --region ${AWS::Region}
|
| 115 |
+
</script>
|
| 116 |
+
- ssmkey: !Ref SSMKey
|
human_reference_dataset/aws-cloudformation-templates/Solutions/CloudFormationEndpointSignals/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Using CloudFormation VPC endpoints with cfn-signal
|
| 2 |
+
|
| 3 |
+
One of the most common use cases for the new CloudFormation VPC endpoints is to
|
| 4 |
+
allow resources within a VPC to signal back to CloudFormation `CreationPolicy`
|
| 5 |
+
and `WaitConditionHandles` without needing to route across the public internet.
|
| 6 |
+
|
| 7 |
+
These example templates demonstrate the bare minimum resources required to use
|
| 8 |
+
`cfn-signal` from inside a private subnet in both cases. Resources using
|
| 9 |
+
`CreationPolicy` (usually EC2 instances and Auto Scaling Groups) can get their
|
| 10 |
+
signals across the CloudFormation endpoint directly, but `WaitConditions` and
|
| 11 |
+
`CustomResources` will also need an S3 endpoint in order to respond to the
|
| 12 |
+
self-signed URLs for those resources.
|
| 13 |
+
|
| 14 |
+
This folder has versions with Internet Gateways and Bastions to allow the end user
|
| 15 |
+
to SSH onto the private EC2 and take a look at what's going on, as well as
|
| 16 |
+
fully self-contained VPCs with no external access other than the VPC endpoints.
|
| 17 |
+
|
| 18 |
+
| Template | CreationPolicy | WaitCondition | IGW/Bastion |
|
| 19 |
+
| ----------------------------------------- | -------------- | ------------- | ----------- |
|
| 20 |
+
| `cfn-endpoint-creationpolicy-no-igw.yaml` | **yes** | no | no |
|
| 21 |
+
| `cfn-endpoint-creationpolicy.yaml` | **yes** | no | **yes** |
|
| 22 |
+
| `cfn-endpoint-waitcondition-no-igw.yaml` | no | **yes** | no |
|
| 23 |
+
| `cfn-endpoint-waitcondition.yaml` | no | **yes** | **yes** |
|
| 24 |
+
|
| 25 |
+
**NOTE:** If you're signaling back from EC2/Auto Scaling, you really should be using `CreationPolicies`. They're easier to configure and have some cool additional features around auto scaling. Save `WaitCondition` for more complex workflow logic.
|
| 26 |
+
|
| 27 |
+
For more information:
|
| 28 |
+
|
| 29 |
+
- [Setting Up VPC Endpoints for AWS CloudFormation
|
| 30 |
+
](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-vpce-bucketnames.html)
|
| 31 |
+
- [Interface VPC Endpoint (for CloudFormation)](https://docs.aws.amazon.com/vpc/latest/userguide/vpce-interface.html)
|
| 32 |
+
- [Gateway VPC Endpoints
|
| 33 |
+
(for S3)](https://docs.aws.amazon.com/vpc/latest/userguide/vpce-gateway.html)
|
| 34 |
+
- [AWS::EC2::VPCEndpoint](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-vpcendpoint.html)
|
| 35 |
+
- [Creating Wait Conditions in a Template](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-waitcondition.html)
|
human_reference_dataset/aws-cloudformation-templates/Solutions/CloudFormationEndpointSignals/cfn-endpoint-creationpolicy-no-igw.json
ADDED
|
@@ -0,0 +1,309 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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template deploys a VPC with a pair of private subnets spread across two Availabilty Zones. It deploys a VPC Endpoint for CloudFormation so an instance in the private subnet can use cfn-signal for its CreationPolicy. **WARNING** You will be billed for the AWS resources used if you create a stack from this template.",
|
| 4 |
+
"Parameters": {
|
| 5 |
+
"EnvironmentName": {
|
| 6 |
+
"Description": "An environment name that will be prefixed to resource names",
|
| 7 |
+
"Type": "String"
|
| 8 |
+
},
|
| 9 |
+
"VpcCIDR": {
|
| 10 |
+
"Description": "Please enter the IP range (CIDR notation) for this VPC",
|
| 11 |
+
"Type": "String",
|
| 12 |
+
"Default": "10.192.0.0/16",
|
| 13 |
+
"AllowedPattern": "((\\d{1,3})\\.){3}\\d{1,3}/\\d{1,2}"
|
| 14 |
+
},
|
| 15 |
+
"PrivateSubnet1CIDR": {
|
| 16 |
+
"Description": "Please enter the IP range (CIDR notation) for the private subnet in the first Availability Zone",
|
| 17 |
+
"Type": "String",
|
| 18 |
+
"Default": "10.192.20.0/24",
|
| 19 |
+
"AllowedPattern": "((\\d{1,3})\\.){3}\\d{1,3}/\\d{1,2}"
|
| 20 |
+
},
|
| 21 |
+
"PrivateSubnet2CIDR": {
|
| 22 |
+
"Description": "Please enter the IP range (CIDR notation) for the private subnet in the second Availability Zone",
|
| 23 |
+
"Type": "String",
|
| 24 |
+
"Default": "10.192.21.0/24",
|
| 25 |
+
"AllowedPattern": "((\\d{1,3})\\.){3}\\d{1,3}/\\d{1,2}"
|
| 26 |
+
},
|
| 27 |
+
"LinuxAMI": {
|
| 28 |
+
"Description": "Managed AMI ID for Amazon Linux",
|
| 29 |
+
"Type": "AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>",
|
| 30 |
+
"Default": "/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-gp2"
|
| 31 |
+
}
|
| 32 |
+
},
|
| 33 |
+
"Resources": {
|
| 34 |
+
"VPC": {
|
| 35 |
+
"Type": "AWS::EC2::VPC",
|
| 36 |
+
"Properties": {
|
| 37 |
+
"EnableDnsSupport": true,
|
| 38 |
+
"EnableDnsHostnames": true,
|
| 39 |
+
"CidrBlock": {
|
| 40 |
+
"Ref": "VpcCIDR"
|
| 41 |
+
},
|
| 42 |
+
"Tags": [
|
| 43 |
+
{
|
| 44 |
+
"Key": "Name",
|
| 45 |
+
"Value": {
|
| 46 |
+
"Ref": "EnvironmentName"
|
| 47 |
+
}
|
| 48 |
+
}
|
| 49 |
+
]
|
| 50 |
+
}
|
| 51 |
+
},
|
| 52 |
+
"CfnEndpoint": {
|
| 53 |
+
"Type": "AWS::EC2::VPCEndpoint",
|
| 54 |
+
"Properties": {
|
| 55 |
+
"VpcId": {
|
| 56 |
+
"Ref": "VPC"
|
| 57 |
+
},
|
| 58 |
+
"ServiceName": {
|
| 59 |
+
"Fn::Sub": "com.amazonaws.${AWS::Region}.cloudformation"
|
| 60 |
+
},
|
| 61 |
+
"VpcEndpointType": "Interface",
|
| 62 |
+
"PrivateDnsEnabled": true,
|
| 63 |
+
"SubnetIds": [
|
| 64 |
+
{
|
| 65 |
+
"Ref": "PrivateSubnet1"
|
| 66 |
+
},
|
| 67 |
+
{
|
| 68 |
+
"Ref": "PrivateSubnet2"
|
| 69 |
+
}
|
| 70 |
+
],
|
| 71 |
+
"SecurityGroupIds": [
|
| 72 |
+
{
|
| 73 |
+
"Ref": "EndpointSG"
|
| 74 |
+
}
|
| 75 |
+
]
|
| 76 |
+
}
|
| 77 |
+
},
|
| 78 |
+
"PrivateSubnet1": {
|
| 79 |
+
"Type": "AWS::EC2::Subnet",
|
| 80 |
+
"Properties": {
|
| 81 |
+
"VpcId": {
|
| 82 |
+
"Ref": "VPC"
|
| 83 |
+
},
|
| 84 |
+
"AvailabilityZone": {
|
| 85 |
+
"Fn::Select": [
|
| 86 |
+
0,
|
| 87 |
+
{
|
| 88 |
+
"Fn::GetAZs": null
|
| 89 |
+
}
|
| 90 |
+
]
|
| 91 |
+
},
|
| 92 |
+
"CidrBlock": {
|
| 93 |
+
"Ref": "PrivateSubnet1CIDR"
|
| 94 |
+
},
|
| 95 |
+
"MapPublicIpOnLaunch": false,
|
| 96 |
+
"Tags": [
|
| 97 |
+
{
|
| 98 |
+
"Key": "Name",
|
| 99 |
+
"Value": {
|
| 100 |
+
"Fn::Sub": "${EnvironmentName} Private Subnet (AZ1)"
|
| 101 |
+
}
|
| 102 |
+
}
|
| 103 |
+
]
|
| 104 |
+
}
|
| 105 |
+
},
|
| 106 |
+
"PrivateSubnet2": {
|
| 107 |
+
"Type": "AWS::EC2::Subnet",
|
| 108 |
+
"Properties": {
|
| 109 |
+
"VpcId": {
|
| 110 |
+
"Ref": "VPC"
|
| 111 |
+
},
|
| 112 |
+
"AvailabilityZone": {
|
| 113 |
+
"Fn::Select": [
|
| 114 |
+
1,
|
| 115 |
+
{
|
| 116 |
+
"Fn::GetAZs": null
|
| 117 |
+
}
|
| 118 |
+
]
|
| 119 |
+
},
|
| 120 |
+
"CidrBlock": {
|
| 121 |
+
"Ref": "PrivateSubnet2CIDR"
|
| 122 |
+
},
|
| 123 |
+
"MapPublicIpOnLaunch": false,
|
| 124 |
+
"Tags": [
|
| 125 |
+
{
|
| 126 |
+
"Key": "Name",
|
| 127 |
+
"Value": {
|
| 128 |
+
"Fn::Sub": "${EnvironmentName} Private Subnet (AZ2)"
|
| 129 |
+
}
|
| 130 |
+
}
|
| 131 |
+
]
|
| 132 |
+
}
|
| 133 |
+
},
|
| 134 |
+
"PrivateRouteTable1": {
|
| 135 |
+
"Type": "AWS::EC2::RouteTable",
|
| 136 |
+
"Properties": {
|
| 137 |
+
"VpcId": {
|
| 138 |
+
"Ref": "VPC"
|
| 139 |
+
},
|
| 140 |
+
"Tags": [
|
| 141 |
+
{
|
| 142 |
+
"Key": "Name",
|
| 143 |
+
"Value": {
|
| 144 |
+
"Fn::Sub": "${EnvironmentName} Private Routes (AZ1)"
|
| 145 |
+
}
|
| 146 |
+
}
|
| 147 |
+
]
|
| 148 |
+
}
|
| 149 |
+
},
|
| 150 |
+
"PrivateSubnet1RouteTableAssociation": {
|
| 151 |
+
"Type": "AWS::EC2::SubnetRouteTableAssociation",
|
| 152 |
+
"Properties": {
|
| 153 |
+
"RouteTableId": {
|
| 154 |
+
"Ref": "PrivateRouteTable1"
|
| 155 |
+
},
|
| 156 |
+
"SubnetId": {
|
| 157 |
+
"Ref": "PrivateSubnet1"
|
| 158 |
+
}
|
| 159 |
+
}
|
| 160 |
+
},
|
| 161 |
+
"PrivateRouteTable2": {
|
| 162 |
+
"Type": "AWS::EC2::RouteTable",
|
| 163 |
+
"Properties": {
|
| 164 |
+
"VpcId": {
|
| 165 |
+
"Ref": "VPC"
|
| 166 |
+
},
|
| 167 |
+
"Tags": [
|
| 168 |
+
{
|
| 169 |
+
"Key": "Name",
|
| 170 |
+
"Value": {
|
| 171 |
+
"Fn::Sub": "${EnvironmentName} Private Routes (AZ2)"
|
| 172 |
+
}
|
| 173 |
+
}
|
| 174 |
+
]
|
| 175 |
+
}
|
| 176 |
+
},
|
| 177 |
+
"PrivateSubnet2RouteTableAssociation": {
|
| 178 |
+
"Type": "AWS::EC2::SubnetRouteTableAssociation",
|
| 179 |
+
"Properties": {
|
| 180 |
+
"RouteTableId": {
|
| 181 |
+
"Ref": "PrivateRouteTable2"
|
| 182 |
+
},
|
| 183 |
+
"SubnetId": {
|
| 184 |
+
"Ref": "PrivateSubnet2"
|
| 185 |
+
}
|
| 186 |
+
}
|
| 187 |
+
},
|
| 188 |
+
"PrivateInstance": {
|
| 189 |
+
"CreationPolicy": {
|
| 190 |
+
"ResourceSignal": {
|
| 191 |
+
"Count": 1,
|
| 192 |
+
"Timeout": "PT15M"
|
| 193 |
+
}
|
| 194 |
+
},
|
| 195 |
+
"Type": "AWS::EC2::Instance",
|
| 196 |
+
"DependsOn": "CfnEndpoint",
|
| 197 |
+
"Properties": {
|
| 198 |
+
"InstanceType": "t3.micro",
|
| 199 |
+
"SecurityGroupIds": [
|
| 200 |
+
{
|
| 201 |
+
"Ref": "PrivateSG"
|
| 202 |
+
}
|
| 203 |
+
],
|
| 204 |
+
"SubnetId": {
|
| 205 |
+
"Ref": "PrivateSubnet1"
|
| 206 |
+
},
|
| 207 |
+
"ImageId": {
|
| 208 |
+
"Ref": "LinuxAMI"
|
| 209 |
+
},
|
| 210 |
+
"UserData": {
|
| 211 |
+
"Fn::Base64": {
|
| 212 |
+
"Fn::Sub": "#!/bin/bash -x\ndate > /tmp/datefile\ncat /tmp/datefile\n# Signal the status from instance\n/opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource PrivateInstance --region ${AWS::Region}\n"
|
| 213 |
+
}
|
| 214 |
+
},
|
| 215 |
+
"Tags": [
|
| 216 |
+
{
|
| 217 |
+
"Key": "Name",
|
| 218 |
+
"Value": "Private"
|
| 219 |
+
}
|
| 220 |
+
]
|
| 221 |
+
}
|
| 222 |
+
},
|
| 223 |
+
"PrivateSG": {
|
| 224 |
+
"Type": "AWS::EC2::SecurityGroup",
|
| 225 |
+
"Metadata": {
|
| 226 |
+
"guard": {
|
| 227 |
+
"SuppressedRules": [
|
| 228 |
+
"INCOMING_SSH_DISABLED"
|
| 229 |
+
]
|
| 230 |
+
}
|
| 231 |
+
},
|
| 232 |
+
"Properties": {
|
| 233 |
+
"GroupDescription": "Traffic from Bastion",
|
| 234 |
+
"SecurityGroupIngress": [
|
| 235 |
+
{
|
| 236 |
+
"IpProtocol": "tcp",
|
| 237 |
+
"FromPort": 22,
|
| 238 |
+
"ToPort": 22,
|
| 239 |
+
"CidrIp": {
|
| 240 |
+
"Ref": "VpcCIDR"
|
| 241 |
+
}
|
| 242 |
+
}
|
| 243 |
+
],
|
| 244 |
+
"VpcId": {
|
| 245 |
+
"Ref": "VPC"
|
| 246 |
+
},
|
| 247 |
+
"Tags": [
|
| 248 |
+
{
|
| 249 |
+
"Key": "Name",
|
| 250 |
+
"Value": "PrivateSG"
|
| 251 |
+
}
|
| 252 |
+
]
|
| 253 |
+
}
|
| 254 |
+
},
|
| 255 |
+
"EndpointSG": {
|
| 256 |
+
"Type": "AWS::EC2::SecurityGroup",
|
| 257 |
+
"Properties": {
|
| 258 |
+
"GroupDescription": "Traffic into CloudFormation Endpoint",
|
| 259 |
+
"SecurityGroupIngress": [
|
| 260 |
+
{
|
| 261 |
+
"IpProtocol": "tcp",
|
| 262 |
+
"FromPort": 443,
|
| 263 |
+
"ToPort": 443,
|
| 264 |
+
"CidrIp": "0.0.0.0/0"
|
| 265 |
+
}
|
| 266 |
+
],
|
| 267 |
+
"VpcId": {
|
| 268 |
+
"Ref": "VPC"
|
| 269 |
+
},
|
| 270 |
+
"Tags": [
|
| 271 |
+
{
|
| 272 |
+
"Key": "Name",
|
| 273 |
+
"Value": "EndpointSG"
|
| 274 |
+
}
|
| 275 |
+
]
|
| 276 |
+
}
|
| 277 |
+
}
|
| 278 |
+
},
|
| 279 |
+
"Outputs": {
|
| 280 |
+
"VPC": {
|
| 281 |
+
"Description": "A reference to the created VPC",
|
| 282 |
+
"Value": {
|
| 283 |
+
"Ref": "VPC"
|
| 284 |
+
}
|
| 285 |
+
},
|
| 286 |
+
"PrivateSubnets": {
|
| 287 |
+
"Description": "A list of the private subnets",
|
| 288 |
+
"Value": {
|
| 289 |
+
"Fn::Join": [
|
| 290 |
+
",",
|
| 291 |
+
[
|
| 292 |
+
{
|
| 293 |
+
"Ref": "PrivateSubnet1"
|
| 294 |
+
},
|
| 295 |
+
{
|
| 296 |
+
"Ref": "PrivateSubnet2"
|
| 297 |
+
}
|
| 298 |
+
]
|
| 299 |
+
]
|
| 300 |
+
}
|
| 301 |
+
},
|
| 302 |
+
"CfnEndpoint": {
|
| 303 |
+
"Description": "A reference to the CloudFormation Endpoint used for signaling from the private instance",
|
| 304 |
+
"Value": {
|
| 305 |
+
"Ref": "CfnEndpoint"
|
| 306 |
+
}
|
| 307 |
+
}
|
| 308 |
+
}
|
| 309 |
+
}
|
human_reference_dataset/aws-cloudformation-templates/Solutions/CloudFormationEndpointSignals/cfn-endpoint-creationpolicy-no-igw.yaml
ADDED
|
@@ -0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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
AWSTemplateFormatVersion: "2010-09-09"
|
| 2 |
+
|
| 3 |
+
Description: This template deploys a VPC with a pair of private subnets spread across two Availabilty Zones. It deploys a VPC Endpoint for CloudFormation so an instance in the private subnet can use cfn-signal for its CreationPolicy. **WARNING** You will be billed for the AWS resources used if you create a stack from this template.
|
| 4 |
+
|
| 5 |
+
Parameters:
|
| 6 |
+
EnvironmentName:
|
| 7 |
+
Description: An environment name that will be prefixed to resource names
|
| 8 |
+
Type: String
|
| 9 |
+
|
| 10 |
+
VpcCIDR:
|
| 11 |
+
Description: Please enter the IP range (CIDR notation) for this VPC
|
| 12 |
+
Type: String
|
| 13 |
+
Default: 10.192.0.0/16
|
| 14 |
+
AllowedPattern: ((\d{1,3})\.){3}\d{1,3}/\d{1,2}
|
| 15 |
+
|
| 16 |
+
PrivateSubnet1CIDR:
|
| 17 |
+
Description: Please enter the IP range (CIDR notation) for the private subnet in the first Availability Zone
|
| 18 |
+
Type: String
|
| 19 |
+
Default: 10.192.20.0/24
|
| 20 |
+
AllowedPattern: ((\d{1,3})\.){3}\d{1,3}/\d{1,2}
|
| 21 |
+
|
| 22 |
+
PrivateSubnet2CIDR:
|
| 23 |
+
Description: Please enter the IP range (CIDR notation) for the private subnet in the second Availability Zone
|
| 24 |
+
Type: String
|
| 25 |
+
Default: 10.192.21.0/24
|
| 26 |
+
AllowedPattern: ((\d{1,3})\.){3}\d{1,3}/\d{1,2}
|
| 27 |
+
|
| 28 |
+
LinuxAMI:
|
| 29 |
+
Description: Managed AMI ID for Amazon Linux
|
| 30 |
+
Type: AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>
|
| 31 |
+
Default: /aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-gp2
|
| 32 |
+
|
| 33 |
+
Resources:
|
| 34 |
+
VPC:
|
| 35 |
+
Type: AWS::EC2::VPC
|
| 36 |
+
Properties:
|
| 37 |
+
EnableDnsSupport: true
|
| 38 |
+
EnableDnsHostnames: true
|
| 39 |
+
CidrBlock: !Ref VpcCIDR
|
| 40 |
+
Tags:
|
| 41 |
+
- Key: Name
|
| 42 |
+
Value: !Ref EnvironmentName
|
| 43 |
+
|
| 44 |
+
# This is the interface endpoint for CloudFormation. You can only deploy this
|
| 45 |
+
# once per region since it will consume the unique DNS entry for the endpoint.
|
| 46 |
+
CfnEndpoint:
|
| 47 |
+
Type: AWS::EC2::VPCEndpoint
|
| 48 |
+
Properties:
|
| 49 |
+
VpcId: !Ref VPC
|
| 50 |
+
ServiceName: !Sub com.amazonaws.${AWS::Region}.cloudformation
|
| 51 |
+
VpcEndpointType: Interface
|
| 52 |
+
PrivateDnsEnabled: true
|
| 53 |
+
SubnetIds:
|
| 54 |
+
- !Ref PrivateSubnet1
|
| 55 |
+
- !Ref PrivateSubnet2
|
| 56 |
+
SecurityGroupIds:
|
| 57 |
+
- !Ref EndpointSG
|
| 58 |
+
|
| 59 |
+
PrivateSubnet1:
|
| 60 |
+
Type: AWS::EC2::Subnet
|
| 61 |
+
Properties:
|
| 62 |
+
VpcId: !Ref VPC
|
| 63 |
+
AvailabilityZone: !Select
|
| 64 |
+
- 0
|
| 65 |
+
- !GetAZs
|
| 66 |
+
CidrBlock: !Ref PrivateSubnet1CIDR
|
| 67 |
+
MapPublicIpOnLaunch: false
|
| 68 |
+
Tags:
|
| 69 |
+
- Key: Name
|
| 70 |
+
Value: !Sub ${EnvironmentName} Private Subnet (AZ1)
|
| 71 |
+
|
| 72 |
+
PrivateSubnet2:
|
| 73 |
+
Type: AWS::EC2::Subnet
|
| 74 |
+
Properties:
|
| 75 |
+
VpcId: !Ref VPC
|
| 76 |
+
AvailabilityZone: !Select
|
| 77 |
+
- 1
|
| 78 |
+
- !GetAZs
|
| 79 |
+
CidrBlock: !Ref PrivateSubnet2CIDR
|
| 80 |
+
MapPublicIpOnLaunch: false
|
| 81 |
+
Tags:
|
| 82 |
+
- Key: Name
|
| 83 |
+
Value: !Sub ${EnvironmentName} Private Subnet (AZ2)
|
| 84 |
+
|
| 85 |
+
PrivateRouteTable1:
|
| 86 |
+
Type: AWS::EC2::RouteTable
|
| 87 |
+
Properties:
|
| 88 |
+
VpcId: !Ref VPC
|
| 89 |
+
Tags:
|
| 90 |
+
- Key: Name
|
| 91 |
+
Value: !Sub ${EnvironmentName} Private Routes (AZ1)
|
| 92 |
+
|
| 93 |
+
PrivateSubnet1RouteTableAssociation:
|
| 94 |
+
Type: AWS::EC2::SubnetRouteTableAssociation
|
| 95 |
+
Properties:
|
| 96 |
+
RouteTableId: !Ref PrivateRouteTable1
|
| 97 |
+
SubnetId: !Ref PrivateSubnet1
|
| 98 |
+
|
| 99 |
+
PrivateRouteTable2:
|
| 100 |
+
Type: AWS::EC2::RouteTable
|
| 101 |
+
Properties:
|
| 102 |
+
VpcId: !Ref VPC
|
| 103 |
+
Tags:
|
| 104 |
+
- Key: Name
|
| 105 |
+
Value: !Sub ${EnvironmentName} Private Routes (AZ2)
|
| 106 |
+
|
| 107 |
+
PrivateSubnet2RouteTableAssociation:
|
| 108 |
+
Type: AWS::EC2::SubnetRouteTableAssociation
|
| 109 |
+
Properties:
|
| 110 |
+
RouteTableId: !Ref PrivateRouteTable2
|
| 111 |
+
SubnetId: !Ref PrivateSubnet2
|
| 112 |
+
|
| 113 |
+
PrivateInstance:
|
| 114 |
+
CreationPolicy:
|
| 115 |
+
ResourceSignal:
|
| 116 |
+
Count: 1
|
| 117 |
+
Timeout: PT15M
|
| 118 |
+
Type: AWS::EC2::Instance
|
| 119 |
+
DependsOn: CfnEndpoint
|
| 120 |
+
Properties:
|
| 121 |
+
InstanceType: t3.micro
|
| 122 |
+
SecurityGroupIds:
|
| 123 |
+
- !Ref PrivateSG
|
| 124 |
+
SubnetId: !Ref PrivateSubnet1
|
| 125 |
+
ImageId: !Ref LinuxAMI
|
| 126 |
+
UserData: !Base64
|
| 127 |
+
Fn::Sub: |
|
| 128 |
+
#!/bin/bash -x
|
| 129 |
+
date > /tmp/datefile
|
| 130 |
+
cat /tmp/datefile
|
| 131 |
+
# Signal the status from instance
|
| 132 |
+
/opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource PrivateInstance --region ${AWS::Region}
|
| 133 |
+
Tags:
|
| 134 |
+
- Key: Name
|
| 135 |
+
Value: Private
|
| 136 |
+
|
| 137 |
+
PrivateSG:
|
| 138 |
+
Type: AWS::EC2::SecurityGroup
|
| 139 |
+
Metadata:
|
| 140 |
+
guard:
|
| 141 |
+
SuppressedRules:
|
| 142 |
+
- INCOMING_SSH_DISABLED
|
| 143 |
+
Properties:
|
| 144 |
+
GroupDescription: Traffic from Bastion
|
| 145 |
+
SecurityGroupIngress:
|
| 146 |
+
- IpProtocol: tcp
|
| 147 |
+
FromPort: 22
|
| 148 |
+
ToPort: 22
|
| 149 |
+
CidrIp: !Ref VpcCIDR
|
| 150 |
+
VpcId: !Ref VPC
|
| 151 |
+
Tags:
|
| 152 |
+
- Key: Name
|
| 153 |
+
Value: PrivateSG
|
| 154 |
+
|
| 155 |
+
EndpointSG:
|
| 156 |
+
Type: AWS::EC2::SecurityGroup
|
| 157 |
+
Properties:
|
| 158 |
+
GroupDescription: Traffic into CloudFormation Endpoint
|
| 159 |
+
SecurityGroupIngress:
|
| 160 |
+
- IpProtocol: tcp
|
| 161 |
+
FromPort: 443
|
| 162 |
+
ToPort: 443
|
| 163 |
+
CidrIp: 0.0.0.0/0
|
| 164 |
+
VpcId: !Ref VPC
|
| 165 |
+
Tags:
|
| 166 |
+
- Key: Name
|
| 167 |
+
Value: EndpointSG
|
| 168 |
+
|
| 169 |
+
Outputs:
|
| 170 |
+
VPC:
|
| 171 |
+
Description: A reference to the created VPC
|
| 172 |
+
Value: !Ref VPC
|
| 173 |
+
|
| 174 |
+
PrivateSubnets:
|
| 175 |
+
Description: A list of the private subnets
|
| 176 |
+
Value: !Join
|
| 177 |
+
- ','
|
| 178 |
+
- - !Ref PrivateSubnet1
|
| 179 |
+
- !Ref PrivateSubnet2
|
| 180 |
+
|
| 181 |
+
CfnEndpoint:
|
| 182 |
+
Description: A reference to the CloudFormation Endpoint used for signaling from the private instance
|
| 183 |
+
Value: !Ref CfnEndpoint
|
human_reference_dataset/aws-cloudformation-templates/Solutions/CloudFormationEndpointSignals/cfn-endpoint-creationpolicy.json
ADDED
|
@@ -0,0 +1,589 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"AWSTemplateFormatVersion": "2010-09-09",
|
| 3 |
+
"Description": "This template deploys a VPC with a pair of public and private subnets spread across two Availabilty Zones. It deploys an Internet Gateway, with a default route on the public subnets and a bastion server. It deploys a VPC Endpoint for CloudFormation so an instance in the private subnet can use cfn-signal for its CreationPolicy. **WARNING** You will be billed for the AWS resources used if you create a stack from this template.\n",
|
| 4 |
+
"Parameters": {
|
| 5 |
+
"EnvironmentName": {
|
| 6 |
+
"Description": "An environment name that will be prefixed to resource names",
|
| 7 |
+
"Type": "String"
|
| 8 |
+
},
|
| 9 |
+
"VpcCIDR": {
|
| 10 |
+
"Description": "Please enter the IP range (CIDR notation) for this VPC",
|
| 11 |
+
"Type": "String",
|
| 12 |
+
"Default": "10.192.0.0/16",
|
| 13 |
+
"AllowedPattern": "((\\d{1,3})\\.){3}\\d{1,3}/\\d{1,2}"
|
| 14 |
+
},
|
| 15 |
+
"PublicSubnet1CIDR": {
|
| 16 |
+
"Description": "Please enter the IP range (CIDR notation) for the public subnet in the first Availability Zone",
|
| 17 |
+
"Type": "String",
|
| 18 |
+
"Default": "10.192.10.0/24",
|
| 19 |
+
"AllowedPattern": "((\\d{1,3})\\.){3}\\d{1,3}/\\d{1,2}"
|
| 20 |
+
},
|
| 21 |
+
"PublicSubnet2CIDR": {
|
| 22 |
+
"Description": "Please enter the IP range (CIDR notation) for the public subnet in the second Availability Zone",
|
| 23 |
+
"Type": "String",
|
| 24 |
+
"Default": "10.192.11.0/24",
|
| 25 |
+
"AllowedPattern": "((\\d{1,3})\\.){3}\\d{1,3}/\\d{1,2}"
|
| 26 |
+
},
|
| 27 |
+
"PrivateSubnet1CIDR": {
|
| 28 |
+
"Description": "Please enter the IP range (CIDR notation) for the private subnet in the first Availability Zone",
|
| 29 |
+
"Type": "String",
|
| 30 |
+
"Default": "10.192.20.0/24",
|
| 31 |
+
"AllowedPattern": "((\\d{1,3})\\.){3}\\d{1,3}/\\d{1,2}"
|
| 32 |
+
},
|
| 33 |
+
"PrivateSubnet2CIDR": {
|
| 34 |
+
"Description": "Please enter the IP range (CIDR notation) for the private subnet in the second Availability Zone",
|
| 35 |
+
"Type": "String",
|
| 36 |
+
"Default": "10.192.21.0/24",
|
| 37 |
+
"AllowedPattern": "((\\d{1,3})\\.){3}\\d{1,3}/\\d{1,2}"
|
| 38 |
+
},
|
| 39 |
+
"KeyName": {
|
| 40 |
+
"Description": "Key pair for EC2 access",
|
| 41 |
+
"Type": "AWS::EC2::KeyPair::KeyName"
|
| 42 |
+
},
|
| 43 |
+
"LinuxAMI": {
|
| 44 |
+
"Description": "Managed AMI ID for Amazon Linux",
|
| 45 |
+
"Type": "AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>",
|
| 46 |
+
"Default": "/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-gp2"
|
| 47 |
+
}
|
| 48 |
+
},
|
| 49 |
+
"Resources": {
|
| 50 |
+
"VPC": {
|
| 51 |
+
"Type": "AWS::EC2::VPC",
|
| 52 |
+
"Properties": {
|
| 53 |
+
"EnableDnsSupport": true,
|
| 54 |
+
"EnableDnsHostnames": true,
|
| 55 |
+
"CidrBlock": {
|
| 56 |
+
"Ref": "VpcCIDR"
|
| 57 |
+
},
|
| 58 |
+
"Tags": [
|
| 59 |
+
{
|
| 60 |
+
"Key": "Name",
|
| 61 |
+
"Value": {
|
| 62 |
+
"Ref": "EnvironmentName"
|
| 63 |
+
}
|
| 64 |
+
}
|
| 65 |
+
]
|
| 66 |
+
}
|
| 67 |
+
},
|
| 68 |
+
"InternetGateway": {
|
| 69 |
+
"Type": "AWS::EC2::InternetGateway",
|
| 70 |
+
"Properties": {
|
| 71 |
+
"Tags": [
|
| 72 |
+
{
|
| 73 |
+
"Key": "Name",
|
| 74 |
+
"Value": {
|
| 75 |
+
"Ref": "EnvironmentName"
|
| 76 |
+
}
|
| 77 |
+
}
|
| 78 |
+
]
|
| 79 |
+
}
|
| 80 |
+
},
|
| 81 |
+
"InternetGatewayAttachment": {
|
| 82 |
+
"Type": "AWS::EC2::VPCGatewayAttachment",
|
| 83 |
+
"Properties": {
|
| 84 |
+
"InternetGatewayId": {
|
| 85 |
+
"Ref": "InternetGateway"
|
| 86 |
+
},
|
| 87 |
+
"VpcId": {
|
| 88 |
+
"Ref": "VPC"
|
| 89 |
+
}
|
| 90 |
+
}
|
| 91 |
+
},
|
| 92 |
+
"CfnEndpoint": {
|
| 93 |
+
"Type": "AWS::EC2::VPCEndpoint",
|
| 94 |
+
"Properties": {
|
| 95 |
+
"VpcId": {
|
| 96 |
+
"Ref": "VPC"
|
| 97 |
+
},
|
| 98 |
+
"ServiceName": {
|
| 99 |
+
"Fn::Sub": "com.amazonaws.${AWS::Region}.cloudformation"
|
| 100 |
+
},
|
| 101 |
+
"VpcEndpointType": "Interface",
|
| 102 |
+
"PrivateDnsEnabled": true,
|
| 103 |
+
"SubnetIds": [
|
| 104 |
+
{
|
| 105 |
+
"Ref": "PrivateSubnet1"
|
| 106 |
+
},
|
| 107 |
+
{
|
| 108 |
+
"Ref": "PrivateSubnet2"
|
| 109 |
+
}
|
| 110 |
+
],
|
| 111 |
+
"SecurityGroupIds": [
|
| 112 |
+
{
|
| 113 |
+
"Ref": "EndpointSG"
|
| 114 |
+
}
|
| 115 |
+
]
|
| 116 |
+
}
|
| 117 |
+
},
|
| 118 |
+
"PublicSubnet1": {
|
| 119 |
+
"Type": "AWS::EC2::Subnet",
|
| 120 |
+
"Properties": {
|
| 121 |
+
"VpcId": {
|
| 122 |
+
"Ref": "VPC"
|
| 123 |
+
},
|
| 124 |
+
"AvailabilityZone": {
|
| 125 |
+
"Fn::Select": [
|
| 126 |
+
0,
|
| 127 |
+
{
|
| 128 |
+
"Fn::GetAZs": null
|
| 129 |
+
}
|
| 130 |
+
]
|
| 131 |
+
},
|
| 132 |
+
"CidrBlock": {
|
| 133 |
+
"Ref": "PublicSubnet1CIDR"
|
| 134 |
+
},
|
| 135 |
+
"MapPublicIpOnLaunch": true,
|
| 136 |
+
"Tags": [
|
| 137 |
+
{
|
| 138 |
+
"Key": "Name",
|
| 139 |
+
"Value": {
|
| 140 |
+
"Fn::Sub": "${EnvironmentName} Public Subnet (AZ1)"
|
| 141 |
+
}
|
| 142 |
+
}
|
| 143 |
+
]
|
| 144 |
+
}
|
| 145 |
+
},
|
| 146 |
+
"PublicSubnet2": {
|
| 147 |
+
"Type": "AWS::EC2::Subnet",
|
| 148 |
+
"Properties": {
|
| 149 |
+
"VpcId": {
|
| 150 |
+
"Ref": "VPC"
|
| 151 |
+
},
|
| 152 |
+
"AvailabilityZone": {
|
| 153 |
+
"Fn::Select": [
|
| 154 |
+
1,
|
| 155 |
+
{
|
| 156 |
+
"Fn::GetAZs": null
|
| 157 |
+
}
|
| 158 |
+
]
|
| 159 |
+
},
|
| 160 |
+
"CidrBlock": {
|
| 161 |
+
"Ref": "PublicSubnet2CIDR"
|
| 162 |
+
},
|
| 163 |
+
"MapPublicIpOnLaunch": true,
|
| 164 |
+
"Tags": [
|
| 165 |
+
{
|
| 166 |
+
"Key": "Name",
|
| 167 |
+
"Value": {
|
| 168 |
+
"Fn::Sub": "${EnvironmentName} Public Subnet (AZ2)"
|
| 169 |
+
}
|
| 170 |
+
}
|
| 171 |
+
]
|
| 172 |
+
}
|
| 173 |
+
},
|
| 174 |
+
"PrivateSubnet1": {
|
| 175 |
+
"Type": "AWS::EC2::Subnet",
|
| 176 |
+
"Properties": {
|
| 177 |
+
"VpcId": {
|
| 178 |
+
"Ref": "VPC"
|
| 179 |
+
},
|
| 180 |
+
"AvailabilityZone": {
|
| 181 |
+
"Fn::Select": [
|
| 182 |
+
0,
|
| 183 |
+
{
|
| 184 |
+
"Fn::GetAZs": null
|
| 185 |
+
}
|
| 186 |
+
]
|
| 187 |
+
},
|
| 188 |
+
"CidrBlock": {
|
| 189 |
+
"Ref": "PrivateSubnet1CIDR"
|
| 190 |
+
},
|
| 191 |
+
"MapPublicIpOnLaunch": false,
|
| 192 |
+
"Tags": [
|
| 193 |
+
{
|
| 194 |
+
"Key": "Name",
|
| 195 |
+
"Value": {
|
| 196 |
+
"Fn::Sub": "${EnvironmentName} Private Subnet (AZ1)"
|
| 197 |
+
}
|
| 198 |
+
}
|
| 199 |
+
]
|
| 200 |
+
}
|
| 201 |
+
},
|
| 202 |
+
"PrivateSubnet2": {
|
| 203 |
+
"Type": "AWS::EC2::Subnet",
|
| 204 |
+
"Properties": {
|
| 205 |
+
"VpcId": {
|
| 206 |
+
"Ref": "VPC"
|
| 207 |
+
},
|
| 208 |
+
"AvailabilityZone": {
|
| 209 |
+
"Fn::Select": [
|
| 210 |
+
1,
|
| 211 |
+
{
|
| 212 |
+
"Fn::GetAZs": null
|
| 213 |
+
}
|
| 214 |
+
]
|
| 215 |
+
},
|
| 216 |
+
"CidrBlock": {
|
| 217 |
+
"Ref": "PrivateSubnet2CIDR"
|
| 218 |
+
},
|
| 219 |
+
"MapPublicIpOnLaunch": false,
|
| 220 |
+
"Tags": [
|
| 221 |
+
{
|
| 222 |
+
"Key": "Name",
|
| 223 |
+
"Value": {
|
| 224 |
+
"Fn::Sub": "${EnvironmentName} Private Subnet (AZ2)"
|
| 225 |
+
}
|
| 226 |
+
}
|
| 227 |
+
]
|
| 228 |
+
}
|
| 229 |
+
},
|
| 230 |
+
"PublicRouteTable": {
|
| 231 |
+
"Type": "AWS::EC2::RouteTable",
|
| 232 |
+
"Properties": {
|
| 233 |
+
"VpcId": {
|
| 234 |
+
"Ref": "VPC"
|
| 235 |
+
},
|
| 236 |
+
"Tags": [
|
| 237 |
+
{
|
| 238 |
+
"Key": "Name",
|
| 239 |
+
"Value": {
|
| 240 |
+
"Fn::Sub": "${EnvironmentName} Public Routes"
|
| 241 |
+
}
|
| 242 |
+
}
|
| 243 |
+
]
|
| 244 |
+
}
|
| 245 |
+
},
|
| 246 |
+
"DefaultPublicRoute": {
|
| 247 |
+
"Type": "AWS::EC2::Route",
|
| 248 |
+
"DependsOn": "InternetGatewayAttachment",
|
| 249 |
+
"Properties": {
|
| 250 |
+
"RouteTableId": {
|
| 251 |
+
"Ref": "PublicRouteTable"
|
| 252 |
+
},
|
| 253 |
+
"DestinationCidrBlock": "0.0.0.0/0",
|
| 254 |
+
"GatewayId": {
|
| 255 |
+
"Ref": "InternetGateway"
|
| 256 |
+
}
|
| 257 |
+
}
|
| 258 |
+
},
|
| 259 |
+
"PublicSubnet1RouteTableAssociation": {
|
| 260 |
+
"Type": "AWS::EC2::SubnetRouteTableAssociation",
|
| 261 |
+
"Properties": {
|
| 262 |
+
"RouteTableId": {
|
| 263 |
+
"Ref": "PublicRouteTable"
|
| 264 |
+
},
|
| 265 |
+
"SubnetId": {
|
| 266 |
+
"Ref": "PublicSubnet1"
|
| 267 |
+
}
|
| 268 |
+
}
|
| 269 |
+
},
|
| 270 |
+
"PublicSubnet2RouteTableAssociation": {
|
| 271 |
+
"Type": "AWS::EC2::SubnetRouteTableAssociation",
|
| 272 |
+
"Properties": {
|
| 273 |
+
"RouteTableId": {
|
| 274 |
+
"Ref": "PublicRouteTable"
|
| 275 |
+
},
|
| 276 |
+
"SubnetId": {
|
| 277 |
+
"Ref": "PublicSubnet2"
|
| 278 |
+
}
|
| 279 |
+
}
|
| 280 |
+
},
|
| 281 |
+
"PrivateRouteTable1": {
|
| 282 |
+
"Type": "AWS::EC2::RouteTable",
|
| 283 |
+
"Properties": {
|
| 284 |
+
"VpcId": {
|
| 285 |
+
"Ref": "VPC"
|
| 286 |
+
},
|
| 287 |
+
"Tags": [
|
| 288 |
+
{
|
| 289 |
+
"Key": "Name",
|
| 290 |
+
"Value": {
|
| 291 |
+
"Fn::Sub": "${EnvironmentName} Private Routes (AZ1)"
|
| 292 |
+
}
|
| 293 |
+
}
|
| 294 |
+
]
|
| 295 |
+
}
|
| 296 |
+
},
|
| 297 |
+
"PrivateSubnet1RouteTableAssociation": {
|
| 298 |
+
"Type": "AWS::EC2::SubnetRouteTableAssociation",
|
| 299 |
+
"Properties": {
|
| 300 |
+
"RouteTableId": {
|
| 301 |
+
"Ref": "PrivateRouteTable1"
|
| 302 |
+
},
|
| 303 |
+
"SubnetId": {
|
| 304 |
+
"Ref": "PrivateSubnet1"
|
| 305 |
+
}
|
| 306 |
+
}
|
| 307 |
+
},
|
| 308 |
+
"PrivateRouteTable2": {
|
| 309 |
+
"Type": "AWS::EC2::RouteTable",
|
| 310 |
+
"Properties": {
|
| 311 |
+
"VpcId": {
|
| 312 |
+
"Ref": "VPC"
|
| 313 |
+
},
|
| 314 |
+
"Tags": [
|
| 315 |
+
{
|
| 316 |
+
"Key": "Name",
|
| 317 |
+
"Value": {
|
| 318 |
+
"Fn::Sub": "${EnvironmentName} Private Routes (AZ2)"
|
| 319 |
+
}
|
| 320 |
+
}
|
| 321 |
+
]
|
| 322 |
+
}
|
| 323 |
+
},
|
| 324 |
+
"PrivateSubnet2RouteTableAssociation": {
|
| 325 |
+
"Type": "AWS::EC2::SubnetRouteTableAssociation",
|
| 326 |
+
"Properties": {
|
| 327 |
+
"RouteTableId": {
|
| 328 |
+
"Ref": "PrivateRouteTable2"
|
| 329 |
+
},
|
| 330 |
+
"SubnetId": {
|
| 331 |
+
"Ref": "PrivateSubnet2"
|
| 332 |
+
}
|
| 333 |
+
}
|
| 334 |
+
},
|
| 335 |
+
"RootRole": {
|
| 336 |
+
"Type": "AWS::IAM::Role",
|
| 337 |
+
"Properties": {
|
| 338 |
+
"AssumeRolePolicyDocument": {
|
| 339 |
+
"Version": "2012-10-17",
|
| 340 |
+
"Statement": [
|
| 341 |
+
{
|
| 342 |
+
"Effect": "Allow",
|
| 343 |
+
"Principal": {
|
| 344 |
+
"Service": [
|
| 345 |
+
"ec2.amazonaws.com"
|
| 346 |
+
]
|
| 347 |
+
},
|
| 348 |
+
"Action": [
|
| 349 |
+
"sts:AssumeRole"
|
| 350 |
+
]
|
| 351 |
+
}
|
| 352 |
+
]
|
| 353 |
+
},
|
| 354 |
+
"Path": "/",
|
| 355 |
+
"Policies": [
|
| 356 |
+
{
|
| 357 |
+
"PolicyName": "root",
|
| 358 |
+
"PolicyDocument": {
|
| 359 |
+
"Version": "2012-10-17",
|
| 360 |
+
"Statement": [
|
| 361 |
+
{
|
| 362 |
+
"Effect": "Allow",
|
| 363 |
+
"Action": "cloudformation:*",
|
| 364 |
+
"Resource": "*"
|
| 365 |
+
}
|
| 366 |
+
]
|
| 367 |
+
}
|
| 368 |
+
}
|
| 369 |
+
]
|
| 370 |
+
}
|
| 371 |
+
},
|
| 372 |
+
"BastionInstance": {
|
| 373 |
+
"Type": "AWS::EC2::Instance",
|
| 374 |
+
"Properties": {
|
| 375 |
+
"KeyName": {
|
| 376 |
+
"Ref": "KeyName"
|
| 377 |
+
},
|
| 378 |
+
"InstanceType": "t2.micro",
|
| 379 |
+
"SecurityGroupIds": [
|
| 380 |
+
{
|
| 381 |
+
"Ref": "BastionSG"
|
| 382 |
+
}
|
| 383 |
+
],
|
| 384 |
+
"SubnetId": {
|
| 385 |
+
"Ref": "PublicSubnet1"
|
| 386 |
+
},
|
| 387 |
+
"ImageId": {
|
| 388 |
+
"Ref": "LinuxAMI"
|
| 389 |
+
},
|
| 390 |
+
"IamInstanceProfile": {
|
| 391 |
+
"Ref": "BastionProfile"
|
| 392 |
+
},
|
| 393 |
+
"Tags": [
|
| 394 |
+
{
|
| 395 |
+
"Key": "Name",
|
| 396 |
+
"Value": "Bastion"
|
| 397 |
+
}
|
| 398 |
+
]
|
| 399 |
+
}
|
| 400 |
+
},
|
| 401 |
+
"BastionSG": {
|
| 402 |
+
"Type": "AWS::EC2::SecurityGroup",
|
| 403 |
+
"Metadata": {
|
| 404 |
+
"guard": {
|
| 405 |
+
"SuppressedRules": [
|
| 406 |
+
"INCOMING_SSH_DISABLED"
|
| 407 |
+
]
|
| 408 |
+
}
|
| 409 |
+
},
|
| 410 |
+
"Properties": {
|
| 411 |
+
"GroupDescription": "Inbound Bastion Traffic",
|
| 412 |
+
"SecurityGroupIngress": [
|
| 413 |
+
{
|
| 414 |
+
"IpProtocol": "tcp",
|
| 415 |
+
"FromPort": 22,
|
| 416 |
+
"ToPort": 22,
|
| 417 |
+
"CidrIp": "0.0.0.0/0"
|
| 418 |
+
}
|
| 419 |
+
],
|
| 420 |
+
"VpcId": {
|
| 421 |
+
"Ref": "VPC"
|
| 422 |
+
},
|
| 423 |
+
"Tags": [
|
| 424 |
+
{
|
| 425 |
+
"Key": "Name",
|
| 426 |
+
"Value": "BastionSG"
|
| 427 |
+
}
|
| 428 |
+
]
|
| 429 |
+
}
|
| 430 |
+
},
|
| 431 |
+
"BastionProfile": {
|
| 432 |
+
"Type": "AWS::IAM::InstanceProfile",
|
| 433 |
+
"Properties": {
|
| 434 |
+
"Path": "/",
|
| 435 |
+
"Roles": [
|
| 436 |
+
{
|
| 437 |
+
"Ref": "RootRole"
|
| 438 |
+
}
|
| 439 |
+
]
|
| 440 |
+
}
|
| 441 |
+
},
|
| 442 |
+
"PrivateInstance": {
|
| 443 |
+
"CreationPolicy": {
|
| 444 |
+
"ResourceSignal": {
|
| 445 |
+
"Count": 1,
|
| 446 |
+
"Timeout": "PT15M"
|
| 447 |
+
}
|
| 448 |
+
},
|
| 449 |
+
"Type": "AWS::EC2::Instance",
|
| 450 |
+
"DependsOn": "CfnEndpoint",
|
| 451 |
+
"Properties": {
|
| 452 |
+
"KeyName": {
|
| 453 |
+
"Ref": "KeyName"
|
| 454 |
+
},
|
| 455 |
+
"InstanceType": "t2.micro",
|
| 456 |
+
"SecurityGroupIds": [
|
| 457 |
+
{
|
| 458 |
+
"Ref": "PrivateSG"
|
| 459 |
+
}
|
| 460 |
+
],
|
| 461 |
+
"SubnetId": {
|
| 462 |
+
"Ref": "PrivateSubnet1"
|
| 463 |
+
},
|
| 464 |
+
"ImageId": {
|
| 465 |
+
"Ref": "LinuxAMI"
|
| 466 |
+
},
|
| 467 |
+
"IamInstanceProfile": {
|
| 468 |
+
"Ref": "PrivateProfile"
|
| 469 |
+
},
|
| 470 |
+
"UserData": {
|
| 471 |
+
"Fn::Base64": {
|
| 472 |
+
"Fn::Sub": "#!/bin/bash -x\ndate > /tmp/datefile\ncat /tmp/datefile\n# Signal the status from instance\n/opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource PrivateInstance --region ${AWS::Region}\n"
|
| 473 |
+
}
|
| 474 |
+
},
|
| 475 |
+
"Tags": [
|
| 476 |
+
{
|
| 477 |
+
"Key": "Name",
|
| 478 |
+
"Value": "Private"
|
| 479 |
+
}
|
| 480 |
+
]
|
| 481 |
+
}
|
| 482 |
+
},
|
| 483 |
+
"PrivateSG": {
|
| 484 |
+
"Type": "AWS::EC2::SecurityGroup",
|
| 485 |
+
"Properties": {
|
| 486 |
+
"GroupDescription": "Traffic from Bastion",
|
| 487 |
+
"SecurityGroupIngress": [
|
| 488 |
+
{
|
| 489 |
+
"IpProtocol": "tcp",
|
| 490 |
+
"FromPort": 22,
|
| 491 |
+
"ToPort": 22,
|
| 492 |
+
"SourceSecurityGroupId": {
|
| 493 |
+
"Ref": "BastionSG"
|
| 494 |
+
}
|
| 495 |
+
}
|
| 496 |
+
],
|
| 497 |
+
"VpcId": {
|
| 498 |
+
"Ref": "VPC"
|
| 499 |
+
},
|
| 500 |
+
"Tags": [
|
| 501 |
+
{
|
| 502 |
+
"Key": "Name",
|
| 503 |
+
"Value": "PrivateSG"
|
| 504 |
+
}
|
| 505 |
+
]
|
| 506 |
+
}
|
| 507 |
+
},
|
| 508 |
+
"PrivateProfile": {
|
| 509 |
+
"Type": "AWS::IAM::InstanceProfile",
|
| 510 |
+
"Properties": {
|
| 511 |
+
"Path": "/",
|
| 512 |
+
"Roles": [
|
| 513 |
+
{
|
| 514 |
+
"Ref": "RootRole"
|
| 515 |
+
}
|
| 516 |
+
]
|
| 517 |
+
}
|
| 518 |
+
},
|
| 519 |
+
"EndpointSG": {
|
| 520 |
+
"Type": "AWS::EC2::SecurityGroup",
|
| 521 |
+
"Properties": {
|
| 522 |
+
"GroupDescription": "Traffic into CloudFormation Endpoint",
|
| 523 |
+
"SecurityGroupIngress": [
|
| 524 |
+
{
|
| 525 |
+
"IpProtocol": "tcp",
|
| 526 |
+
"FromPort": 443,
|
| 527 |
+
"ToPort": 443,
|
| 528 |
+
"CidrIp": "0.0.0.0/0"
|
| 529 |
+
}
|
| 530 |
+
],
|
| 531 |
+
"VpcId": {
|
| 532 |
+
"Ref": "VPC"
|
| 533 |
+
},
|
| 534 |
+
"Tags": [
|
| 535 |
+
{
|
| 536 |
+
"Key": "Name",
|
| 537 |
+
"Value": "EndpointSG"
|
| 538 |
+
}
|
| 539 |
+
]
|
| 540 |
+
}
|
| 541 |
+
}
|
| 542 |
+
},
|
| 543 |
+
"Outputs": {
|
| 544 |
+
"VPC": {
|
| 545 |
+
"Description": "A reference to the created VPC",
|
| 546 |
+
"Value": {
|
| 547 |
+
"Ref": "VPC"
|
| 548 |
+
}
|
| 549 |
+
},
|
| 550 |
+
"PublicSubnets": {
|
| 551 |
+
"Description": "A list of the public subnets",
|
| 552 |
+
"Value": {
|
| 553 |
+
"Fn::Join": [
|
| 554 |
+
",",
|
| 555 |
+
[
|
| 556 |
+
{
|
| 557 |
+
"Ref": "PublicSubnet1"
|
| 558 |
+
},
|
| 559 |
+
{
|
| 560 |
+
"Ref": "PublicSubnet2"
|
| 561 |
+
}
|
| 562 |
+
]
|
| 563 |
+
]
|
| 564 |
+
}
|
| 565 |
+
},
|
| 566 |
+
"PrivateSubnets": {
|
| 567 |
+
"Description": "A list of the private subnets",
|
| 568 |
+
"Value": {
|
| 569 |
+
"Fn::Join": [
|
| 570 |
+
",",
|
| 571 |
+
[
|
| 572 |
+
{
|
| 573 |
+
"Ref": "PrivateSubnet1"
|
| 574 |
+
},
|
| 575 |
+
{
|
| 576 |
+
"Ref": "PrivateSubnet2"
|
| 577 |
+
}
|
| 578 |
+
]
|
| 579 |
+
]
|
| 580 |
+
}
|
| 581 |
+
},
|
| 582 |
+
"CfnEndpoint": {
|
| 583 |
+
"Description": "A reference to the CloudFormation Endpoint used for signaling from the private instance",
|
| 584 |
+
"Value": {
|
| 585 |
+
"Ref": "CfnEndpoint"
|
| 586 |
+
}
|
| 587 |
+
}
|
| 588 |
+
}
|
| 589 |
+
}
|
human_reference_dataset/aws-cloudformation-templates/Solutions/CloudFormationEndpointSignals/cfn-endpoint-creationpolicy.yaml
ADDED
|
@@ -0,0 +1,340 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
AWSTemplateFormatVersion: "2010-09-09"
|
| 2 |
+
|
| 3 |
+
Description: |
|
| 4 |
+
This template deploys a VPC with a pair of public and private subnets spread across two Availabilty Zones. It deploys an Internet Gateway, with a default route on the public subnets and a bastion server. It deploys a VPC Endpoint for CloudFormation so an instance in the private subnet can use cfn-signal for its CreationPolicy. **WARNING** You will be billed for the AWS resources used if you create a stack from this template.
|
| 5 |
+
|
| 6 |
+
Parameters:
|
| 7 |
+
EnvironmentName:
|
| 8 |
+
Description: An environment name that will be prefixed to resource names
|
| 9 |
+
Type: String
|
| 10 |
+
|
| 11 |
+
VpcCIDR:
|
| 12 |
+
Description: Please enter the IP range (CIDR notation) for this VPC
|
| 13 |
+
Type: String
|
| 14 |
+
Default: 10.192.0.0/16
|
| 15 |
+
AllowedPattern: ((\d{1,3})\.){3}\d{1,3}/\d{1,2}
|
| 16 |
+
|
| 17 |
+
PublicSubnet1CIDR:
|
| 18 |
+
Description: Please enter the IP range (CIDR notation) for the public subnet in the first Availability Zone
|
| 19 |
+
Type: String
|
| 20 |
+
Default: 10.192.10.0/24
|
| 21 |
+
AllowedPattern: ((\d{1,3})\.){3}\d{1,3}/\d{1,2}
|
| 22 |
+
|
| 23 |
+
PublicSubnet2CIDR:
|
| 24 |
+
Description: Please enter the IP range (CIDR notation) for the public subnet in the second Availability Zone
|
| 25 |
+
Type: String
|
| 26 |
+
Default: 10.192.11.0/24
|
| 27 |
+
AllowedPattern: ((\d{1,3})\.){3}\d{1,3}/\d{1,2}
|
| 28 |
+
|
| 29 |
+
PrivateSubnet1CIDR:
|
| 30 |
+
Description: Please enter the IP range (CIDR notation) for the private subnet in the first Availability Zone
|
| 31 |
+
Type: String
|
| 32 |
+
Default: 10.192.20.0/24
|
| 33 |
+
AllowedPattern: ((\d{1,3})\.){3}\d{1,3}/\d{1,2}
|
| 34 |
+
|
| 35 |
+
PrivateSubnet2CIDR:
|
| 36 |
+
Description: Please enter the IP range (CIDR notation) for the private subnet in the second Availability Zone
|
| 37 |
+
Type: String
|
| 38 |
+
Default: 10.192.21.0/24
|
| 39 |
+
AllowedPattern: ((\d{1,3})\.){3}\d{1,3}/\d{1,2}
|
| 40 |
+
|
| 41 |
+
KeyName:
|
| 42 |
+
Description: Key pair for EC2 access
|
| 43 |
+
Type: AWS::EC2::KeyPair::KeyName
|
| 44 |
+
|
| 45 |
+
LinuxAMI:
|
| 46 |
+
Description: Managed AMI ID for Amazon Linux
|
| 47 |
+
Type: AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>
|
| 48 |
+
Default: /aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-gp2
|
| 49 |
+
|
| 50 |
+
Resources:
|
| 51 |
+
VPC:
|
| 52 |
+
Type: AWS::EC2::VPC
|
| 53 |
+
Properties:
|
| 54 |
+
EnableDnsSupport: true
|
| 55 |
+
EnableDnsHostnames: true
|
| 56 |
+
CidrBlock: !Ref VpcCIDR
|
| 57 |
+
Tags:
|
| 58 |
+
- Key: Name
|
| 59 |
+
Value: !Ref EnvironmentName
|
| 60 |
+
|
| 61 |
+
InternetGateway:
|
| 62 |
+
Type: AWS::EC2::InternetGateway
|
| 63 |
+
Properties:
|
| 64 |
+
Tags:
|
| 65 |
+
- Key: Name
|
| 66 |
+
Value: !Ref EnvironmentName
|
| 67 |
+
|
| 68 |
+
InternetGatewayAttachment:
|
| 69 |
+
Type: AWS::EC2::VPCGatewayAttachment
|
| 70 |
+
Properties:
|
| 71 |
+
InternetGatewayId: !Ref InternetGateway
|
| 72 |
+
VpcId: !Ref VPC
|
| 73 |
+
|
| 74 |
+
# This is the interface endpoint for CloudFormation. You can only deploy this
|
| 75 |
+
# once per region since it will consume the unique DNS entry for the endpoint.
|
| 76 |
+
CfnEndpoint:
|
| 77 |
+
Type: AWS::EC2::VPCEndpoint
|
| 78 |
+
Properties:
|
| 79 |
+
VpcId: !Ref VPC
|
| 80 |
+
ServiceName: !Sub com.amazonaws.${AWS::Region}.cloudformation
|
| 81 |
+
VpcEndpointType: Interface
|
| 82 |
+
PrivateDnsEnabled: true
|
| 83 |
+
SubnetIds:
|
| 84 |
+
- !Ref PrivateSubnet1
|
| 85 |
+
- !Ref PrivateSubnet2
|
| 86 |
+
SecurityGroupIds:
|
| 87 |
+
- !Ref EndpointSG
|
| 88 |
+
|
| 89 |
+
PublicSubnet1:
|
| 90 |
+
Type: AWS::EC2::Subnet
|
| 91 |
+
Properties:
|
| 92 |
+
VpcId: !Ref VPC
|
| 93 |
+
AvailabilityZone: !Select
|
| 94 |
+
- 0
|
| 95 |
+
- !GetAZs
|
| 96 |
+
CidrBlock: !Ref PublicSubnet1CIDR
|
| 97 |
+
MapPublicIpOnLaunch: true
|
| 98 |
+
Tags:
|
| 99 |
+
- Key: Name
|
| 100 |
+
Value: !Sub ${EnvironmentName} Public Subnet (AZ1)
|
| 101 |
+
|
| 102 |
+
PublicSubnet2:
|
| 103 |
+
Type: AWS::EC2::Subnet
|
| 104 |
+
Properties:
|
| 105 |
+
VpcId: !Ref VPC
|
| 106 |
+
AvailabilityZone: !Select
|
| 107 |
+
- 1
|
| 108 |
+
- !GetAZs
|
| 109 |
+
CidrBlock: !Ref PublicSubnet2CIDR
|
| 110 |
+
MapPublicIpOnLaunch: true
|
| 111 |
+
Tags:
|
| 112 |
+
- Key: Name
|
| 113 |
+
Value: !Sub ${EnvironmentName} Public Subnet (AZ2)
|
| 114 |
+
|
| 115 |
+
PrivateSubnet1:
|
| 116 |
+
Type: AWS::EC2::Subnet
|
| 117 |
+
Properties:
|
| 118 |
+
VpcId: !Ref VPC
|
| 119 |
+
AvailabilityZone: !Select
|
| 120 |
+
- 0
|
| 121 |
+
- !GetAZs
|
| 122 |
+
CidrBlock: !Ref PrivateSubnet1CIDR
|
| 123 |
+
MapPublicIpOnLaunch: false
|
| 124 |
+
Tags:
|
| 125 |
+
- Key: Name
|
| 126 |
+
Value: !Sub ${EnvironmentName} Private Subnet (AZ1)
|
| 127 |
+
|
| 128 |
+
PrivateSubnet2:
|
| 129 |
+
Type: AWS::EC2::Subnet
|
| 130 |
+
Properties:
|
| 131 |
+
VpcId: !Ref VPC
|
| 132 |
+
AvailabilityZone: !Select
|
| 133 |
+
- 1
|
| 134 |
+
- !GetAZs
|
| 135 |
+
CidrBlock: !Ref PrivateSubnet2CIDR
|
| 136 |
+
MapPublicIpOnLaunch: false
|
| 137 |
+
Tags:
|
| 138 |
+
- Key: Name
|
| 139 |
+
Value: !Sub ${EnvironmentName} Private Subnet (AZ2)
|
| 140 |
+
|
| 141 |
+
PublicRouteTable:
|
| 142 |
+
Type: AWS::EC2::RouteTable
|
| 143 |
+
Properties:
|
| 144 |
+
VpcId: !Ref VPC
|
| 145 |
+
Tags:
|
| 146 |
+
- Key: Name
|
| 147 |
+
Value: !Sub ${EnvironmentName} Public Routes
|
| 148 |
+
|
| 149 |
+
DefaultPublicRoute:
|
| 150 |
+
Type: AWS::EC2::Route
|
| 151 |
+
DependsOn: InternetGatewayAttachment
|
| 152 |
+
Properties:
|
| 153 |
+
RouteTableId: !Ref PublicRouteTable
|
| 154 |
+
DestinationCidrBlock: 0.0.0.0/0
|
| 155 |
+
GatewayId: !Ref InternetGateway
|
| 156 |
+
|
| 157 |
+
PublicSubnet1RouteTableAssociation:
|
| 158 |
+
Type: AWS::EC2::SubnetRouteTableAssociation
|
| 159 |
+
Properties:
|
| 160 |
+
RouteTableId: !Ref PublicRouteTable
|
| 161 |
+
SubnetId: !Ref PublicSubnet1
|
| 162 |
+
|
| 163 |
+
PublicSubnet2RouteTableAssociation:
|
| 164 |
+
Type: AWS::EC2::SubnetRouteTableAssociation
|
| 165 |
+
Properties:
|
| 166 |
+
RouteTableId: !Ref PublicRouteTable
|
| 167 |
+
SubnetId: !Ref PublicSubnet2
|
| 168 |
+
|
| 169 |
+
PrivateRouteTable1:
|
| 170 |
+
Type: AWS::EC2::RouteTable
|
| 171 |
+
Properties:
|
| 172 |
+
VpcId: !Ref VPC
|
| 173 |
+
Tags:
|
| 174 |
+
- Key: Name
|
| 175 |
+
Value: !Sub ${EnvironmentName} Private Routes (AZ1)
|
| 176 |
+
|
| 177 |
+
PrivateSubnet1RouteTableAssociation:
|
| 178 |
+
Type: AWS::EC2::SubnetRouteTableAssociation
|
| 179 |
+
Properties:
|
| 180 |
+
RouteTableId: !Ref PrivateRouteTable1
|
| 181 |
+
SubnetId: !Ref PrivateSubnet1
|
| 182 |
+
|
| 183 |
+
PrivateRouteTable2:
|
| 184 |
+
Type: AWS::EC2::RouteTable
|
| 185 |
+
Properties:
|
| 186 |
+
VpcId: !Ref VPC
|
| 187 |
+
Tags:
|
| 188 |
+
- Key: Name
|
| 189 |
+
Value: !Sub ${EnvironmentName} Private Routes (AZ2)
|
| 190 |
+
|
| 191 |
+
PrivateSubnet2RouteTableAssociation:
|
| 192 |
+
Type: AWS::EC2::SubnetRouteTableAssociation
|
| 193 |
+
Properties:
|
| 194 |
+
RouteTableId: !Ref PrivateRouteTable2
|
| 195 |
+
SubnetId: !Ref PrivateSubnet2
|
| 196 |
+
|
| 197 |
+
RootRole:
|
| 198 |
+
Type: AWS::IAM::Role
|
| 199 |
+
Properties:
|
| 200 |
+
AssumeRolePolicyDocument:
|
| 201 |
+
Version: "2012-10-17"
|
| 202 |
+
Statement:
|
| 203 |
+
- Effect: Allow
|
| 204 |
+
Principal:
|
| 205 |
+
Service:
|
| 206 |
+
- ec2.amazonaws.com
|
| 207 |
+
Action:
|
| 208 |
+
- sts:AssumeRole
|
| 209 |
+
Path: /
|
| 210 |
+
Policies:
|
| 211 |
+
- PolicyName: root
|
| 212 |
+
PolicyDocument:
|
| 213 |
+
Version: "2012-10-17"
|
| 214 |
+
Statement:
|
| 215 |
+
- Effect: Allow
|
| 216 |
+
Action: cloudformation:*
|
| 217 |
+
Resource: '*'
|
| 218 |
+
|
| 219 |
+
BastionInstance:
|
| 220 |
+
Type: AWS::EC2::Instance
|
| 221 |
+
Properties:
|
| 222 |
+
KeyName: !Ref KeyName
|
| 223 |
+
InstanceType: t2.micro
|
| 224 |
+
SecurityGroupIds:
|
| 225 |
+
- !Ref BastionSG
|
| 226 |
+
SubnetId: !Ref PublicSubnet1
|
| 227 |
+
ImageId: !Ref LinuxAMI
|
| 228 |
+
IamInstanceProfile: !Ref BastionProfile
|
| 229 |
+
Tags:
|
| 230 |
+
- Key: Name
|
| 231 |
+
Value: Bastion
|
| 232 |
+
|
| 233 |
+
BastionSG:
|
| 234 |
+
Type: AWS::EC2::SecurityGroup
|
| 235 |
+
Metadata:
|
| 236 |
+
guard:
|
| 237 |
+
SuppressedRules:
|
| 238 |
+
- INCOMING_SSH_DISABLED
|
| 239 |
+
Properties:
|
| 240 |
+
GroupDescription: Inbound Bastion Traffic
|
| 241 |
+
SecurityGroupIngress:
|
| 242 |
+
- IpProtocol: tcp
|
| 243 |
+
FromPort: 22
|
| 244 |
+
ToPort: 22
|
| 245 |
+
CidrIp: 0.0.0.0/0
|
| 246 |
+
VpcId: !Ref VPC
|
| 247 |
+
Tags:
|
| 248 |
+
- Key: Name
|
| 249 |
+
Value: BastionSG
|
| 250 |
+
|
| 251 |
+
BastionProfile:
|
| 252 |
+
Type: AWS::IAM::InstanceProfile
|
| 253 |
+
Properties:
|
| 254 |
+
Path: /
|
| 255 |
+
Roles:
|
| 256 |
+
- !Ref RootRole
|
| 257 |
+
|
| 258 |
+
PrivateInstance:
|
| 259 |
+
CreationPolicy:
|
| 260 |
+
ResourceSignal:
|
| 261 |
+
Count: 1
|
| 262 |
+
Timeout: PT15M
|
| 263 |
+
Type: AWS::EC2::Instance
|
| 264 |
+
DependsOn: CfnEndpoint
|
| 265 |
+
Properties:
|
| 266 |
+
KeyName: !Ref KeyName
|
| 267 |
+
InstanceType: t2.micro
|
| 268 |
+
SecurityGroupIds:
|
| 269 |
+
- !Ref PrivateSG
|
| 270 |
+
SubnetId: !Ref PrivateSubnet1
|
| 271 |
+
ImageId: !Ref LinuxAMI
|
| 272 |
+
IamInstanceProfile: !Ref PrivateProfile
|
| 273 |
+
UserData: !Base64
|
| 274 |
+
Fn::Sub: |
|
| 275 |
+
#!/bin/bash -x
|
| 276 |
+
date > /tmp/datefile
|
| 277 |
+
cat /tmp/datefile
|
| 278 |
+
# Signal the status from instance
|
| 279 |
+
/opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource PrivateInstance --region ${AWS::Region}
|
| 280 |
+
Tags:
|
| 281 |
+
- Key: Name
|
| 282 |
+
Value: Private
|
| 283 |
+
|
| 284 |
+
PrivateSG:
|
| 285 |
+
Type: AWS::EC2::SecurityGroup
|
| 286 |
+
Properties:
|
| 287 |
+
GroupDescription: Traffic from Bastion
|
| 288 |
+
SecurityGroupIngress:
|
| 289 |
+
- IpProtocol: tcp
|
| 290 |
+
FromPort: 22
|
| 291 |
+
ToPort: 22
|
| 292 |
+
SourceSecurityGroupId: !Ref BastionSG
|
| 293 |
+
VpcId: !Ref VPC
|
| 294 |
+
Tags:
|
| 295 |
+
- Key: Name
|
| 296 |
+
Value: PrivateSG
|
| 297 |
+
|
| 298 |
+
PrivateProfile:
|
| 299 |
+
Type: AWS::IAM::InstanceProfile
|
| 300 |
+
Properties:
|
| 301 |
+
Path: /
|
| 302 |
+
Roles:
|
| 303 |
+
- !Ref RootRole
|
| 304 |
+
|
| 305 |
+
EndpointSG:
|
| 306 |
+
Type: AWS::EC2::SecurityGroup
|
| 307 |
+
Properties:
|
| 308 |
+
GroupDescription: Traffic into CloudFormation Endpoint
|
| 309 |
+
SecurityGroupIngress:
|
| 310 |
+
- IpProtocol: tcp
|
| 311 |
+
FromPort: 443
|
| 312 |
+
ToPort: 443
|
| 313 |
+
CidrIp: 0.0.0.0/0
|
| 314 |
+
VpcId: !Ref VPC
|
| 315 |
+
Tags:
|
| 316 |
+
- Key: Name
|
| 317 |
+
Value: EndpointSG
|
| 318 |
+
|
| 319 |
+
Outputs:
|
| 320 |
+
VPC:
|
| 321 |
+
Description: A reference to the created VPC
|
| 322 |
+
Value: !Ref VPC
|
| 323 |
+
|
| 324 |
+
PublicSubnets:
|
| 325 |
+
Description: A list of the public subnets
|
| 326 |
+
Value: !Join
|
| 327 |
+
- ','
|
| 328 |
+
- - !Ref PublicSubnet1
|
| 329 |
+
- !Ref PublicSubnet2
|
| 330 |
+
|
| 331 |
+
PrivateSubnets:
|
| 332 |
+
Description: A list of the private subnets
|
| 333 |
+
Value: !Join
|
| 334 |
+
- ','
|
| 335 |
+
- - !Ref PrivateSubnet1
|
| 336 |
+
- !Ref PrivateSubnet2
|
| 337 |
+
|
| 338 |
+
CfnEndpoint:
|
| 339 |
+
Description: A reference to the CloudFormation Endpoint used for signaling from the private instance
|
| 340 |
+
Value: !Ref CfnEndpoint
|
human_reference_dataset/aws-cloudformation-templates/Solutions/CloudFormationEndpointSignals/cfn-endpoint-waitcondition-no-igw.json
ADDED
|
@@ -0,0 +1,360 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"AWSTemplateFormatVersion": "2010-09-09",
|
| 3 |
+
"Description": "This template deploys a VPC with a pair of private subnets spread across two Availabilty Zones. It deploys VPC Endpoints for CloudFormation and S3 so an instance in the private subnet can use cfn-signal for a WaitCondition. **WARNING** You will be billed for the AWS resources used if you create a stack from this template.\n",
|
| 4 |
+
"Parameters": {
|
| 5 |
+
"EnvironmentName": {
|
| 6 |
+
"Description": "An environment name that will be prefixed to resource names",
|
| 7 |
+
"Type": "String"
|
| 8 |
+
},
|
| 9 |
+
"VpcCIDR": {
|
| 10 |
+
"Description": "Please enter the IP range (CIDR notation) for this VPC",
|
| 11 |
+
"Type": "String",
|
| 12 |
+
"Default": "10.192.0.0/16",
|
| 13 |
+
"AllowedPattern": "((\\d{1,3})\\.){3}\\d{1,3}/\\d{1,2}"
|
| 14 |
+
},
|
| 15 |
+
"PrivateSubnet1CIDR": {
|
| 16 |
+
"Description": "Please enter the IP range (CIDR notation) for the private subnet in the first Availability Zone",
|
| 17 |
+
"Type": "String",
|
| 18 |
+
"Default": "10.192.20.0/24",
|
| 19 |
+
"AllowedPattern": "((\\d{1,3})\\.){3}\\d{1,3}/\\d{1,2}"
|
| 20 |
+
},
|
| 21 |
+
"PrivateSubnet2CIDR": {
|
| 22 |
+
"Description": "Please enter the IP range (CIDR notation) for the private subnet in the second Availability Zone",
|
| 23 |
+
"Type": "String",
|
| 24 |
+
"Default": "10.192.21.0/24",
|
| 25 |
+
"AllowedPattern": "((\\d{1,3})\\.){3}\\d{1,3}/\\d{1,2}"
|
| 26 |
+
},
|
| 27 |
+
"LinuxAMI": {
|
| 28 |
+
"Description": "Managed AMI ID for Amazon Linux",
|
| 29 |
+
"Type": "AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>",
|
| 30 |
+
"Default": "/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-gp2"
|
| 31 |
+
}
|
| 32 |
+
},
|
| 33 |
+
"Resources": {
|
| 34 |
+
"VPC": {
|
| 35 |
+
"Type": "AWS::EC2::VPC",
|
| 36 |
+
"Properties": {
|
| 37 |
+
"EnableDnsSupport": true,
|
| 38 |
+
"EnableDnsHostnames": true,
|
| 39 |
+
"CidrBlock": {
|
| 40 |
+
"Ref": "VpcCIDR"
|
| 41 |
+
},
|
| 42 |
+
"Tags": [
|
| 43 |
+
{
|
| 44 |
+
"Key": "Name",
|
| 45 |
+
"Value": {
|
| 46 |
+
"Ref": "EnvironmentName"
|
| 47 |
+
}
|
| 48 |
+
}
|
| 49 |
+
]
|
| 50 |
+
}
|
| 51 |
+
},
|
| 52 |
+
"CfnEndpoint": {
|
| 53 |
+
"Type": "AWS::EC2::VPCEndpoint",
|
| 54 |
+
"Properties": {
|
| 55 |
+
"VpcId": {
|
| 56 |
+
"Ref": "VPC"
|
| 57 |
+
},
|
| 58 |
+
"ServiceName": {
|
| 59 |
+
"Fn::Sub": "com.amazonaws.${AWS::Region}.cloudformation"
|
| 60 |
+
},
|
| 61 |
+
"VpcEndpointType": "Interface",
|
| 62 |
+
"PrivateDnsEnabled": true,
|
| 63 |
+
"SubnetIds": [
|
| 64 |
+
{
|
| 65 |
+
"Ref": "PrivateSubnet1"
|
| 66 |
+
},
|
| 67 |
+
{
|
| 68 |
+
"Ref": "PrivateSubnet2"
|
| 69 |
+
}
|
| 70 |
+
],
|
| 71 |
+
"SecurityGroupIds": [
|
| 72 |
+
{
|
| 73 |
+
"Ref": "EndpointSG"
|
| 74 |
+
}
|
| 75 |
+
]
|
| 76 |
+
}
|
| 77 |
+
},
|
| 78 |
+
"S3Endpoint": {
|
| 79 |
+
"Type": "AWS::EC2::VPCEndpoint",
|
| 80 |
+
"Properties": {
|
| 81 |
+
"VpcId": {
|
| 82 |
+
"Ref": "VPC"
|
| 83 |
+
},
|
| 84 |
+
"ServiceName": {
|
| 85 |
+
"Fn::Sub": "com.amazonaws.${AWS::Region}.s3"
|
| 86 |
+
},
|
| 87 |
+
"VpcEndpointType": "Gateway",
|
| 88 |
+
"PolicyDocument": {
|
| 89 |
+
"Version": "2012-10-17",
|
| 90 |
+
"Statement": [
|
| 91 |
+
{
|
| 92 |
+
"Effect": "Allow",
|
| 93 |
+
"Principal": "*",
|
| 94 |
+
"Action": [
|
| 95 |
+
"s3:PutObject"
|
| 96 |
+
],
|
| 97 |
+
"Resource": [
|
| 98 |
+
{
|
| 99 |
+
"Fn::Sub": "arn:${AWS::Partition}:s3:::cloudformation-waitcondition-${AWS::Region}/*"
|
| 100 |
+
}
|
| 101 |
+
]
|
| 102 |
+
}
|
| 103 |
+
]
|
| 104 |
+
},
|
| 105 |
+
"RouteTableIds": [
|
| 106 |
+
{
|
| 107 |
+
"Ref": "PrivateRouteTable1"
|
| 108 |
+
},
|
| 109 |
+
{
|
| 110 |
+
"Ref": "PrivateRouteTable2"
|
| 111 |
+
}
|
| 112 |
+
]
|
| 113 |
+
}
|
| 114 |
+
},
|
| 115 |
+
"PrivateSubnet1": {
|
| 116 |
+
"Type": "AWS::EC2::Subnet",
|
| 117 |
+
"Properties": {
|
| 118 |
+
"VpcId": {
|
| 119 |
+
"Ref": "VPC"
|
| 120 |
+
},
|
| 121 |
+
"AvailabilityZone": {
|
| 122 |
+
"Fn::Select": [
|
| 123 |
+
0,
|
| 124 |
+
{
|
| 125 |
+
"Fn::GetAZs": null
|
| 126 |
+
}
|
| 127 |
+
]
|
| 128 |
+
},
|
| 129 |
+
"CidrBlock": {
|
| 130 |
+
"Ref": "PrivateSubnet1CIDR"
|
| 131 |
+
},
|
| 132 |
+
"MapPublicIpOnLaunch": false,
|
| 133 |
+
"Tags": [
|
| 134 |
+
{
|
| 135 |
+
"Key": "Name",
|
| 136 |
+
"Value": {
|
| 137 |
+
"Fn::Sub": "${EnvironmentName} Private Subnet (AZ1)"
|
| 138 |
+
}
|
| 139 |
+
}
|
| 140 |
+
]
|
| 141 |
+
}
|
| 142 |
+
},
|
| 143 |
+
"PrivateSubnet2": {
|
| 144 |
+
"Type": "AWS::EC2::Subnet",
|
| 145 |
+
"Properties": {
|
| 146 |
+
"VpcId": {
|
| 147 |
+
"Ref": "VPC"
|
| 148 |
+
},
|
| 149 |
+
"AvailabilityZone": {
|
| 150 |
+
"Fn::Select": [
|
| 151 |
+
1,
|
| 152 |
+
{
|
| 153 |
+
"Fn::GetAZs": null
|
| 154 |
+
}
|
| 155 |
+
]
|
| 156 |
+
},
|
| 157 |
+
"CidrBlock": {
|
| 158 |
+
"Ref": "PrivateSubnet2CIDR"
|
| 159 |
+
},
|
| 160 |
+
"MapPublicIpOnLaunch": false,
|
| 161 |
+
"Tags": [
|
| 162 |
+
{
|
| 163 |
+
"Key": "Name",
|
| 164 |
+
"Value": {
|
| 165 |
+
"Fn::Sub": "${EnvironmentName} Private Subnet (AZ2)"
|
| 166 |
+
}
|
| 167 |
+
}
|
| 168 |
+
]
|
| 169 |
+
}
|
| 170 |
+
},
|
| 171 |
+
"PrivateRouteTable1": {
|
| 172 |
+
"Type": "AWS::EC2::RouteTable",
|
| 173 |
+
"Properties": {
|
| 174 |
+
"VpcId": {
|
| 175 |
+
"Ref": "VPC"
|
| 176 |
+
},
|
| 177 |
+
"Tags": [
|
| 178 |
+
{
|
| 179 |
+
"Key": "Name",
|
| 180 |
+
"Value": {
|
| 181 |
+
"Fn::Sub": "${EnvironmentName} Private Routes (AZ1)"
|
| 182 |
+
}
|
| 183 |
+
}
|
| 184 |
+
]
|
| 185 |
+
}
|
| 186 |
+
},
|
| 187 |
+
"PrivateSubnet1RouteTableAssociation": {
|
| 188 |
+
"Type": "AWS::EC2::SubnetRouteTableAssociation",
|
| 189 |
+
"Properties": {
|
| 190 |
+
"RouteTableId": {
|
| 191 |
+
"Ref": "PrivateRouteTable1"
|
| 192 |
+
},
|
| 193 |
+
"SubnetId": {
|
| 194 |
+
"Ref": "PrivateSubnet1"
|
| 195 |
+
}
|
| 196 |
+
}
|
| 197 |
+
},
|
| 198 |
+
"PrivateRouteTable2": {
|
| 199 |
+
"Type": "AWS::EC2::RouteTable",
|
| 200 |
+
"Properties": {
|
| 201 |
+
"VpcId": {
|
| 202 |
+
"Ref": "VPC"
|
| 203 |
+
},
|
| 204 |
+
"Tags": [
|
| 205 |
+
{
|
| 206 |
+
"Key": "Name",
|
| 207 |
+
"Value": {
|
| 208 |
+
"Fn::Sub": "${EnvironmentName} Private Routes (AZ2)"
|
| 209 |
+
}
|
| 210 |
+
}
|
| 211 |
+
]
|
| 212 |
+
}
|
| 213 |
+
},
|
| 214 |
+
"PrivateSubnet2RouteTableAssociation": {
|
| 215 |
+
"Type": "AWS::EC2::SubnetRouteTableAssociation",
|
| 216 |
+
"Properties": {
|
| 217 |
+
"RouteTableId": {
|
| 218 |
+
"Ref": "PrivateRouteTable2"
|
| 219 |
+
},
|
| 220 |
+
"SubnetId": {
|
| 221 |
+
"Ref": "PrivateSubnet2"
|
| 222 |
+
}
|
| 223 |
+
}
|
| 224 |
+
},
|
| 225 |
+
"PrivateInstance": {
|
| 226 |
+
"Type": "AWS::EC2::Instance",
|
| 227 |
+
"DependsOn": "CfnEndpoint",
|
| 228 |
+
"Properties": {
|
| 229 |
+
"InstanceType": "t3.micro",
|
| 230 |
+
"SecurityGroupIds": [
|
| 231 |
+
{
|
| 232 |
+
"Ref": "PrivateSG"
|
| 233 |
+
}
|
| 234 |
+
],
|
| 235 |
+
"SubnetId": {
|
| 236 |
+
"Ref": "PrivateSubnet1"
|
| 237 |
+
},
|
| 238 |
+
"ImageId": {
|
| 239 |
+
"Ref": "LinuxAMI"
|
| 240 |
+
},
|
| 241 |
+
"UserData": {
|
| 242 |
+
"Fn::Base64": {
|
| 243 |
+
"Fn::Sub": "#!/bin/bash -x\ndate > /tmp/datefile\ncat /tmp/datefile\n# Signal the status from instance\n/opt/aws/bin/cfn-signal -e $? -d \"This was all private.\" -r \"Build Process Complete\" '${PrivateWaitHandle}'\n"
|
| 244 |
+
}
|
| 245 |
+
},
|
| 246 |
+
"Tags": [
|
| 247 |
+
{
|
| 248 |
+
"Key": "Name",
|
| 249 |
+
"Value": "Private"
|
| 250 |
+
}
|
| 251 |
+
]
|
| 252 |
+
}
|
| 253 |
+
},
|
| 254 |
+
"PrivateSG": {
|
| 255 |
+
"Type": "AWS::EC2::SecurityGroup",
|
| 256 |
+
"Metadata": {
|
| 257 |
+
"guard": {
|
| 258 |
+
"SuppressedRules": [
|
| 259 |
+
"INCOMING_SSH_DISABLED"
|
| 260 |
+
]
|
| 261 |
+
}
|
| 262 |
+
},
|
| 263 |
+
"Properties": {
|
| 264 |
+
"GroupDescription": "Traffic from Bastion",
|
| 265 |
+
"SecurityGroupIngress": [
|
| 266 |
+
{
|
| 267 |
+
"IpProtocol": "tcp",
|
| 268 |
+
"FromPort": 22,
|
| 269 |
+
"ToPort": 22,
|
| 270 |
+
"CidrIp": {
|
| 271 |
+
"Ref": "VpcCIDR"
|
| 272 |
+
}
|
| 273 |
+
}
|
| 274 |
+
],
|
| 275 |
+
"VpcId": {
|
| 276 |
+
"Ref": "VPC"
|
| 277 |
+
},
|
| 278 |
+
"Tags": [
|
| 279 |
+
{
|
| 280 |
+
"Key": "Name",
|
| 281 |
+
"Value": "PrivateSG"
|
| 282 |
+
}
|
| 283 |
+
]
|
| 284 |
+
}
|
| 285 |
+
},
|
| 286 |
+
"EndpointSG": {
|
| 287 |
+
"Type": "AWS::EC2::SecurityGroup",
|
| 288 |
+
"Properties": {
|
| 289 |
+
"GroupDescription": "Traffic into CloudFormation Endpoint",
|
| 290 |
+
"SecurityGroupIngress": [
|
| 291 |
+
{
|
| 292 |
+
"IpProtocol": "tcp",
|
| 293 |
+
"FromPort": 443,
|
| 294 |
+
"ToPort": 443,
|
| 295 |
+
"CidrIp": "0.0.0.0/0"
|
| 296 |
+
}
|
| 297 |
+
],
|
| 298 |
+
"VpcId": {
|
| 299 |
+
"Ref": "VPC"
|
| 300 |
+
},
|
| 301 |
+
"Tags": [
|
| 302 |
+
{
|
| 303 |
+
"Key": "Name",
|
| 304 |
+
"Value": "EndpointSG"
|
| 305 |
+
}
|
| 306 |
+
]
|
| 307 |
+
}
|
| 308 |
+
},
|
| 309 |
+
"PrivateWaitHandle": {
|
| 310 |
+
"Type": "AWS::CloudFormation::WaitConditionHandle"
|
| 311 |
+
},
|
| 312 |
+
"PrivateWaitCondition": {
|
| 313 |
+
"Type": "AWS::CloudFormation::WaitCondition",
|
| 314 |
+
"DependsOn": "PrivateInstance",
|
| 315 |
+
"Properties": {
|
| 316 |
+
"Handle": {
|
| 317 |
+
"Ref": "PrivateWaitHandle"
|
| 318 |
+
},
|
| 319 |
+
"Timeout": "3600",
|
| 320 |
+
"Count": 1
|
| 321 |
+
}
|
| 322 |
+
}
|
| 323 |
+
},
|
| 324 |
+
"Outputs": {
|
| 325 |
+
"VPC": {
|
| 326 |
+
"Description": "A reference to the created VPC",
|
| 327 |
+
"Value": {
|
| 328 |
+
"Ref": "VPC"
|
| 329 |
+
}
|
| 330 |
+
},
|
| 331 |
+
"PrivateSubnets": {
|
| 332 |
+
"Description": "A list of the private subnets",
|
| 333 |
+
"Value": {
|
| 334 |
+
"Fn::Join": [
|
| 335 |
+
",",
|
| 336 |
+
[
|
| 337 |
+
{
|
| 338 |
+
"Ref": "PrivateSubnet1"
|
| 339 |
+
},
|
| 340 |
+
{
|
| 341 |
+
"Ref": "PrivateSubnet2"
|
| 342 |
+
}
|
| 343 |
+
]
|
| 344 |
+
]
|
| 345 |
+
}
|
| 346 |
+
},
|
| 347 |
+
"CfnEndpoint": {
|
| 348 |
+
"Description": "A reference to the CloudFormation Endpoint used for signaling from the private instance",
|
| 349 |
+
"Value": {
|
| 350 |
+
"Ref": "CfnEndpoint"
|
| 351 |
+
}
|
| 352 |
+
},
|
| 353 |
+
"S3Endpoint": {
|
| 354 |
+
"Description": "A reference to the S3 Endpoint used for signaling from the private instance",
|
| 355 |
+
"Value": {
|
| 356 |
+
"Ref": "S3Endpoint"
|
| 357 |
+
}
|
| 358 |
+
}
|
| 359 |
+
}
|
| 360 |
+
}
|
human_reference_dataset/aws-cloudformation-templates/Solutions/CloudFormationEndpointSignals/cfn-endpoint-waitcondition-no-igw.yaml
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
AWSTemplateFormatVersion: "2010-09-09"
|
| 2 |
+
|
| 3 |
+
Description: |
|
| 4 |
+
This template deploys a VPC with a pair of private subnets spread across two Availabilty Zones. It deploys VPC Endpoints for CloudFormation and S3 so an instance in the private subnet can use cfn-signal for a WaitCondition. **WARNING** You will be billed for the AWS resources used if you create a stack from this template.
|
| 5 |
+
|
| 6 |
+
Parameters:
|
| 7 |
+
EnvironmentName:
|
| 8 |
+
Description: An environment name that will be prefixed to resource names
|
| 9 |
+
Type: String
|
| 10 |
+
|
| 11 |
+
VpcCIDR:
|
| 12 |
+
Description: Please enter the IP range (CIDR notation) for this VPC
|
| 13 |
+
Type: String
|
| 14 |
+
Default: 10.192.0.0/16
|
| 15 |
+
AllowedPattern: ((\d{1,3})\.){3}\d{1,3}/\d{1,2}
|
| 16 |
+
|
| 17 |
+
PrivateSubnet1CIDR:
|
| 18 |
+
Description: Please enter the IP range (CIDR notation) for the private subnet in the first Availability Zone
|
| 19 |
+
Type: String
|
| 20 |
+
Default: 10.192.20.0/24
|
| 21 |
+
AllowedPattern: ((\d{1,3})\.){3}\d{1,3}/\d{1,2}
|
| 22 |
+
|
| 23 |
+
PrivateSubnet2CIDR:
|
| 24 |
+
Description: Please enter the IP range (CIDR notation) for the private subnet in the second Availability Zone
|
| 25 |
+
Type: String
|
| 26 |
+
Default: 10.192.21.0/24
|
| 27 |
+
AllowedPattern: ((\d{1,3})\.){3}\d{1,3}/\d{1,2}
|
| 28 |
+
|
| 29 |
+
LinuxAMI:
|
| 30 |
+
Description: Managed AMI ID for Amazon Linux
|
| 31 |
+
Type: AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>
|
| 32 |
+
Default: /aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-gp2
|
| 33 |
+
|
| 34 |
+
Resources:
|
| 35 |
+
VPC:
|
| 36 |
+
Type: AWS::EC2::VPC
|
| 37 |
+
Properties:
|
| 38 |
+
EnableDnsSupport: true
|
| 39 |
+
EnableDnsHostnames: true
|
| 40 |
+
CidrBlock: !Ref VpcCIDR
|
| 41 |
+
Tags:
|
| 42 |
+
- Key: Name
|
| 43 |
+
Value: !Ref EnvironmentName
|
| 44 |
+
|
| 45 |
+
# This is the interface endpoint for CloudFormation. You can only deploy this
|
| 46 |
+
# once per region since it will consume the unique DNS entry for the endpoint.
|
| 47 |
+
CfnEndpoint:
|
| 48 |
+
Type: AWS::EC2::VPCEndpoint
|
| 49 |
+
Properties:
|
| 50 |
+
VpcId: !Ref VPC
|
| 51 |
+
ServiceName: !Sub com.amazonaws.${AWS::Region}.cloudformation
|
| 52 |
+
VpcEndpointType: Interface
|
| 53 |
+
PrivateDnsEnabled: true
|
| 54 |
+
SubnetIds:
|
| 55 |
+
- !Ref PrivateSubnet1
|
| 56 |
+
- !Ref PrivateSubnet2
|
| 57 |
+
SecurityGroupIds:
|
| 58 |
+
- !Ref EndpointSG
|
| 59 |
+
|
| 60 |
+
# This is the gateway endpoint for S3. WaitConditions and CustomResources
|
| 61 |
+
# need to access self-signed URLs in the following buckets to signal back
|
| 62 |
+
# to the stack.
|
| 63 |
+
S3Endpoint:
|
| 64 |
+
Type: AWS::EC2::VPCEndpoint
|
| 65 |
+
Properties:
|
| 66 |
+
VpcId: !Ref VPC
|
| 67 |
+
ServiceName: !Sub com.amazonaws.${AWS::Region}.s3
|
| 68 |
+
VpcEndpointType: Gateway
|
| 69 |
+
PolicyDocument:
|
| 70 |
+
Version: "2012-10-17"
|
| 71 |
+
Statement:
|
| 72 |
+
- Effect: Allow
|
| 73 |
+
Principal: '*'
|
| 74 |
+
Action:
|
| 75 |
+
- s3:PutObject
|
| 76 |
+
Resource:
|
| 77 |
+
- !Sub arn:${AWS::Partition}:s3:::cloudformation-waitcondition-${AWS::Region}/*
|
| 78 |
+
RouteTableIds:
|
| 79 |
+
- !Ref PrivateRouteTable1
|
| 80 |
+
- !Ref PrivateRouteTable2
|
| 81 |
+
|
| 82 |
+
PrivateSubnet1:
|
| 83 |
+
Type: AWS::EC2::Subnet
|
| 84 |
+
Properties:
|
| 85 |
+
VpcId: !Ref VPC
|
| 86 |
+
AvailabilityZone: !Select
|
| 87 |
+
- 0
|
| 88 |
+
- !GetAZs
|
| 89 |
+
CidrBlock: !Ref PrivateSubnet1CIDR
|
| 90 |
+
MapPublicIpOnLaunch: false
|
| 91 |
+
Tags:
|
| 92 |
+
- Key: Name
|
| 93 |
+
Value: !Sub ${EnvironmentName} Private Subnet (AZ1)
|
| 94 |
+
|
| 95 |
+
PrivateSubnet2:
|
| 96 |
+
Type: AWS::EC2::Subnet
|
| 97 |
+
Properties:
|
| 98 |
+
VpcId: !Ref VPC
|
| 99 |
+
AvailabilityZone: !Select
|
| 100 |
+
- 1
|
| 101 |
+
- !GetAZs
|
| 102 |
+
CidrBlock: !Ref PrivateSubnet2CIDR
|
| 103 |
+
MapPublicIpOnLaunch: false
|
| 104 |
+
Tags:
|
| 105 |
+
- Key: Name
|
| 106 |
+
Value: !Sub ${EnvironmentName} Private Subnet (AZ2)
|
| 107 |
+
|
| 108 |
+
PrivateRouteTable1:
|
| 109 |
+
Type: AWS::EC2::RouteTable
|
| 110 |
+
Properties:
|
| 111 |
+
VpcId: !Ref VPC
|
| 112 |
+
Tags:
|
| 113 |
+
- Key: Name
|
| 114 |
+
Value: !Sub ${EnvironmentName} Private Routes (AZ1)
|
| 115 |
+
|
| 116 |
+
PrivateSubnet1RouteTableAssociation:
|
| 117 |
+
Type: AWS::EC2::SubnetRouteTableAssociation
|
| 118 |
+
Properties:
|
| 119 |
+
RouteTableId: !Ref PrivateRouteTable1
|
| 120 |
+
SubnetId: !Ref PrivateSubnet1
|
| 121 |
+
|
| 122 |
+
PrivateRouteTable2:
|
| 123 |
+
Type: AWS::EC2::RouteTable
|
| 124 |
+
Properties:
|
| 125 |
+
VpcId: !Ref VPC
|
| 126 |
+
Tags:
|
| 127 |
+
- Key: Name
|
| 128 |
+
Value: !Sub ${EnvironmentName} Private Routes (AZ2)
|
| 129 |
+
|
| 130 |
+
PrivateSubnet2RouteTableAssociation:
|
| 131 |
+
Type: AWS::EC2::SubnetRouteTableAssociation
|
| 132 |
+
Properties:
|
| 133 |
+
RouteTableId: !Ref PrivateRouteTable2
|
| 134 |
+
SubnetId: !Ref PrivateSubnet2
|
| 135 |
+
|
| 136 |
+
PrivateInstance:
|
| 137 |
+
Type: AWS::EC2::Instance
|
| 138 |
+
DependsOn: CfnEndpoint
|
| 139 |
+
Properties:
|
| 140 |
+
InstanceType: t3.micro
|
| 141 |
+
SecurityGroupIds:
|
| 142 |
+
- !Ref PrivateSG
|
| 143 |
+
SubnetId: !Ref PrivateSubnet1
|
| 144 |
+
ImageId: !Ref LinuxAMI
|
| 145 |
+
UserData: !Base64
|
| 146 |
+
Fn::Sub: |
|
| 147 |
+
#!/bin/bash -x
|
| 148 |
+
date > /tmp/datefile
|
| 149 |
+
cat /tmp/datefile
|
| 150 |
+
# Signal the status from instance
|
| 151 |
+
/opt/aws/bin/cfn-signal -e $? -d "This was all private." -r "Build Process Complete" '${PrivateWaitHandle}'
|
| 152 |
+
Tags:
|
| 153 |
+
- Key: Name
|
| 154 |
+
Value: Private
|
| 155 |
+
|
| 156 |
+
PrivateSG:
|
| 157 |
+
Type: AWS::EC2::SecurityGroup
|
| 158 |
+
Metadata:
|
| 159 |
+
guard:
|
| 160 |
+
SuppressedRules:
|
| 161 |
+
- INCOMING_SSH_DISABLED
|
| 162 |
+
Properties:
|
| 163 |
+
GroupDescription: Traffic from Bastion
|
| 164 |
+
SecurityGroupIngress:
|
| 165 |
+
- IpProtocol: tcp
|
| 166 |
+
FromPort: 22
|
| 167 |
+
ToPort: 22
|
| 168 |
+
CidrIp: !Ref VpcCIDR
|
| 169 |
+
VpcId: !Ref VPC
|
| 170 |
+
Tags:
|
| 171 |
+
- Key: Name
|
| 172 |
+
Value: PrivateSG
|
| 173 |
+
|
| 174 |
+
EndpointSG:
|
| 175 |
+
Type: AWS::EC2::SecurityGroup
|
| 176 |
+
Properties:
|
| 177 |
+
GroupDescription: Traffic into CloudFormation Endpoint
|
| 178 |
+
SecurityGroupIngress:
|
| 179 |
+
- IpProtocol: tcp
|
| 180 |
+
FromPort: 443
|
| 181 |
+
ToPort: 443
|
| 182 |
+
CidrIp: 0.0.0.0/0
|
| 183 |
+
VpcId: !Ref VPC
|
| 184 |
+
Tags:
|
| 185 |
+
- Key: Name
|
| 186 |
+
Value: EndpointSG
|
| 187 |
+
|
| 188 |
+
PrivateWaitHandle:
|
| 189 |
+
Type: AWS::CloudFormation::WaitConditionHandle
|
| 190 |
+
|
| 191 |
+
PrivateWaitCondition:
|
| 192 |
+
Type: AWS::CloudFormation::WaitCondition
|
| 193 |
+
DependsOn: PrivateInstance
|
| 194 |
+
Properties:
|
| 195 |
+
Handle: !Ref PrivateWaitHandle
|
| 196 |
+
Timeout: "3600"
|
| 197 |
+
Count: 1
|
| 198 |
+
|
| 199 |
+
Outputs:
|
| 200 |
+
VPC:
|
| 201 |
+
Description: A reference to the created VPC
|
| 202 |
+
Value: !Ref VPC
|
| 203 |
+
|
| 204 |
+
PrivateSubnets:
|
| 205 |
+
Description: A list of the private subnets
|
| 206 |
+
Value: !Join
|
| 207 |
+
- ','
|
| 208 |
+
- - !Ref PrivateSubnet1
|
| 209 |
+
- !Ref PrivateSubnet2
|
| 210 |
+
|
| 211 |
+
CfnEndpoint:
|
| 212 |
+
Description: A reference to the CloudFormation Endpoint used for signaling from the private instance
|
| 213 |
+
Value: !Ref CfnEndpoint
|
| 214 |
+
|
| 215 |
+
S3Endpoint:
|
| 216 |
+
Description: A reference to the S3 Endpoint used for signaling from the private instance
|
| 217 |
+
Value: !Ref S3Endpoint
|
human_reference_dataset/aws-cloudformation-templates/Solutions/CloudFormationEndpointSignals/cfn-endpoint-waitcondition.json
ADDED
|
@@ -0,0 +1,640 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"AWSTemplateFormatVersion": "2010-09-09",
|
| 3 |
+
"Description": "This template deploys a VPC with a pair of public and private subnets spread across two Availabilty Zones. It deploys an Internet Gateway, with a default route on the public subnets and a bastion server. It deploys VPC Endpoints for CloudFormation and S3 so an instance in the private subnet can use cfn-signal for a WaitCondition. **WARNING** You will be billed for the AWS resources used if you create a stack from this template.\n",
|
| 4 |
+
"Parameters": {
|
| 5 |
+
"EnvironmentName": {
|
| 6 |
+
"Description": "An environment name that will be prefixed to resource names",
|
| 7 |
+
"Type": "String"
|
| 8 |
+
},
|
| 9 |
+
"VpcCIDR": {
|
| 10 |
+
"Description": "Please enter the IP range (CIDR notation) for this VPC",
|
| 11 |
+
"Type": "String",
|
| 12 |
+
"Default": "10.192.0.0/16",
|
| 13 |
+
"AllowedPattern": "((\\d{1,3})\\.){3}\\d{1,3}/\\d{1,2}"
|
| 14 |
+
},
|
| 15 |
+
"PublicSubnet1CIDR": {
|
| 16 |
+
"Description": "Please enter the IP range (CIDR notation) for the public subnet in the first Availability Zone",
|
| 17 |
+
"Type": "String",
|
| 18 |
+
"Default": "10.192.10.0/24",
|
| 19 |
+
"AllowedPattern": "((\\d{1,3})\\.){3}\\d{1,3}/\\d{1,2}"
|
| 20 |
+
},
|
| 21 |
+
"PublicSubnet2CIDR": {
|
| 22 |
+
"Description": "Please enter the IP range (CIDR notation) for the public subnet in the second Availability Zone",
|
| 23 |
+
"Type": "String",
|
| 24 |
+
"Default": "10.192.11.0/24",
|
| 25 |
+
"AllowedPattern": "((\\d{1,3})\\.){3}\\d{1,3}/\\d{1,2}"
|
| 26 |
+
},
|
| 27 |
+
"PrivateSubnet1CIDR": {
|
| 28 |
+
"Description": "Please enter the IP range (CIDR notation) for the private subnet in the first Availability Zone",
|
| 29 |
+
"Type": "String",
|
| 30 |
+
"Default": "10.192.20.0/24",
|
| 31 |
+
"AllowedPattern": "((\\d{1,3})\\.){3}\\d{1,3}/\\d{1,2}"
|
| 32 |
+
},
|
| 33 |
+
"PrivateSubnet2CIDR": {
|
| 34 |
+
"Description": "Please enter the IP range (CIDR notation) for the private subnet in the second Availability Zone",
|
| 35 |
+
"Type": "String",
|
| 36 |
+
"Default": "10.192.21.0/24",
|
| 37 |
+
"AllowedPattern": "((\\d{1,3})\\.){3}\\d{1,3}/\\d{1,2}"
|
| 38 |
+
},
|
| 39 |
+
"KeyName": {
|
| 40 |
+
"Description": "Key pair for EC2 access",
|
| 41 |
+
"Type": "AWS::EC2::KeyPair::KeyName"
|
| 42 |
+
},
|
| 43 |
+
"LinuxAMI": {
|
| 44 |
+
"Description": "Managed AMI ID for Amazon Linux",
|
| 45 |
+
"Type": "AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>",
|
| 46 |
+
"Default": "/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-gp2"
|
| 47 |
+
}
|
| 48 |
+
},
|
| 49 |
+
"Resources": {
|
| 50 |
+
"VPC": {
|
| 51 |
+
"Type": "AWS::EC2::VPC",
|
| 52 |
+
"Properties": {
|
| 53 |
+
"EnableDnsSupport": true,
|
| 54 |
+
"EnableDnsHostnames": true,
|
| 55 |
+
"CidrBlock": {
|
| 56 |
+
"Ref": "VpcCIDR"
|
| 57 |
+
},
|
| 58 |
+
"Tags": [
|
| 59 |
+
{
|
| 60 |
+
"Key": "Name",
|
| 61 |
+
"Value": {
|
| 62 |
+
"Ref": "EnvironmentName"
|
| 63 |
+
}
|
| 64 |
+
}
|
| 65 |
+
]
|
| 66 |
+
}
|
| 67 |
+
},
|
| 68 |
+
"InternetGateway": {
|
| 69 |
+
"Type": "AWS::EC2::InternetGateway",
|
| 70 |
+
"Properties": {
|
| 71 |
+
"Tags": [
|
| 72 |
+
{
|
| 73 |
+
"Key": "Name",
|
| 74 |
+
"Value": {
|
| 75 |
+
"Ref": "EnvironmentName"
|
| 76 |
+
}
|
| 77 |
+
}
|
| 78 |
+
]
|
| 79 |
+
}
|
| 80 |
+
},
|
| 81 |
+
"InternetGatewayAttachment": {
|
| 82 |
+
"Type": "AWS::EC2::VPCGatewayAttachment",
|
| 83 |
+
"Properties": {
|
| 84 |
+
"InternetGatewayId": {
|
| 85 |
+
"Ref": "InternetGateway"
|
| 86 |
+
},
|
| 87 |
+
"VpcId": {
|
| 88 |
+
"Ref": "VPC"
|
| 89 |
+
}
|
| 90 |
+
}
|
| 91 |
+
},
|
| 92 |
+
"CfnEndpoint": {
|
| 93 |
+
"Type": "AWS::EC2::VPCEndpoint",
|
| 94 |
+
"Properties": {
|
| 95 |
+
"VpcId": {
|
| 96 |
+
"Ref": "VPC"
|
| 97 |
+
},
|
| 98 |
+
"ServiceName": {
|
| 99 |
+
"Fn::Sub": "com.amazonaws.${AWS::Region}.cloudformation"
|
| 100 |
+
},
|
| 101 |
+
"VpcEndpointType": "Interface",
|
| 102 |
+
"PrivateDnsEnabled": true,
|
| 103 |
+
"SubnetIds": [
|
| 104 |
+
{
|
| 105 |
+
"Ref": "PrivateSubnet1"
|
| 106 |
+
},
|
| 107 |
+
{
|
| 108 |
+
"Ref": "PrivateSubnet2"
|
| 109 |
+
}
|
| 110 |
+
],
|
| 111 |
+
"SecurityGroupIds": [
|
| 112 |
+
{
|
| 113 |
+
"Ref": "EndpointSG"
|
| 114 |
+
}
|
| 115 |
+
]
|
| 116 |
+
}
|
| 117 |
+
},
|
| 118 |
+
"S3Endpoint": {
|
| 119 |
+
"Type": "AWS::EC2::VPCEndpoint",
|
| 120 |
+
"Properties": {
|
| 121 |
+
"VpcId": {
|
| 122 |
+
"Ref": "VPC"
|
| 123 |
+
},
|
| 124 |
+
"ServiceName": {
|
| 125 |
+
"Fn::Sub": "com.amazonaws.${AWS::Region}.s3"
|
| 126 |
+
},
|
| 127 |
+
"VpcEndpointType": "Gateway",
|
| 128 |
+
"PolicyDocument": {
|
| 129 |
+
"Version": "2012-10-17",
|
| 130 |
+
"Statement": [
|
| 131 |
+
{
|
| 132 |
+
"Effect": "Allow",
|
| 133 |
+
"Principal": "*",
|
| 134 |
+
"Action": [
|
| 135 |
+
"s3:PutObject"
|
| 136 |
+
],
|
| 137 |
+
"Resource": [
|
| 138 |
+
{
|
| 139 |
+
"Fn::Sub": "arn:${AWS::Partition}:s3:::cloudformation-waitcondition-${AWS::Region}/*"
|
| 140 |
+
}
|
| 141 |
+
]
|
| 142 |
+
}
|
| 143 |
+
]
|
| 144 |
+
},
|
| 145 |
+
"RouteTableIds": [
|
| 146 |
+
{
|
| 147 |
+
"Ref": "PrivateRouteTable1"
|
| 148 |
+
},
|
| 149 |
+
{
|
| 150 |
+
"Ref": "PrivateRouteTable2"
|
| 151 |
+
}
|
| 152 |
+
]
|
| 153 |
+
}
|
| 154 |
+
},
|
| 155 |
+
"PublicSubnet1": {
|
| 156 |
+
"Type": "AWS::EC2::Subnet",
|
| 157 |
+
"Properties": {
|
| 158 |
+
"VpcId": {
|
| 159 |
+
"Ref": "VPC"
|
| 160 |
+
},
|
| 161 |
+
"AvailabilityZone": {
|
| 162 |
+
"Fn::Select": [
|
| 163 |
+
0,
|
| 164 |
+
{
|
| 165 |
+
"Fn::GetAZs": null
|
| 166 |
+
}
|
| 167 |
+
]
|
| 168 |
+
},
|
| 169 |
+
"CidrBlock": {
|
| 170 |
+
"Ref": "PublicSubnet1CIDR"
|
| 171 |
+
},
|
| 172 |
+
"MapPublicIpOnLaunch": true,
|
| 173 |
+
"Tags": [
|
| 174 |
+
{
|
| 175 |
+
"Key": "Name",
|
| 176 |
+
"Value": {
|
| 177 |
+
"Fn::Sub": "${EnvironmentName} Public Subnet (AZ1)"
|
| 178 |
+
}
|
| 179 |
+
}
|
| 180 |
+
]
|
| 181 |
+
}
|
| 182 |
+
},
|
| 183 |
+
"PublicSubnet2": {
|
| 184 |
+
"Type": "AWS::EC2::Subnet",
|
| 185 |
+
"Properties": {
|
| 186 |
+
"VpcId": {
|
| 187 |
+
"Ref": "VPC"
|
| 188 |
+
},
|
| 189 |
+
"AvailabilityZone": {
|
| 190 |
+
"Fn::Select": [
|
| 191 |
+
1,
|
| 192 |
+
{
|
| 193 |
+
"Fn::GetAZs": null
|
| 194 |
+
}
|
| 195 |
+
]
|
| 196 |
+
},
|
| 197 |
+
"CidrBlock": {
|
| 198 |
+
"Ref": "PublicSubnet2CIDR"
|
| 199 |
+
},
|
| 200 |
+
"MapPublicIpOnLaunch": true,
|
| 201 |
+
"Tags": [
|
| 202 |
+
{
|
| 203 |
+
"Key": "Name",
|
| 204 |
+
"Value": {
|
| 205 |
+
"Fn::Sub": "${EnvironmentName} Public Subnet (AZ2)"
|
| 206 |
+
}
|
| 207 |
+
}
|
| 208 |
+
]
|
| 209 |
+
}
|
| 210 |
+
},
|
| 211 |
+
"PrivateSubnet1": {
|
| 212 |
+
"Type": "AWS::EC2::Subnet",
|
| 213 |
+
"Properties": {
|
| 214 |
+
"VpcId": {
|
| 215 |
+
"Ref": "VPC"
|
| 216 |
+
},
|
| 217 |
+
"AvailabilityZone": {
|
| 218 |
+
"Fn::Select": [
|
| 219 |
+
0,
|
| 220 |
+
{
|
| 221 |
+
"Fn::GetAZs": null
|
| 222 |
+
}
|
| 223 |
+
]
|
| 224 |
+
},
|
| 225 |
+
"CidrBlock": {
|
| 226 |
+
"Ref": "PrivateSubnet1CIDR"
|
| 227 |
+
},
|
| 228 |
+
"MapPublicIpOnLaunch": false,
|
| 229 |
+
"Tags": [
|
| 230 |
+
{
|
| 231 |
+
"Key": "Name",
|
| 232 |
+
"Value": {
|
| 233 |
+
"Fn::Sub": "${EnvironmentName} Private Subnet (AZ1)"
|
| 234 |
+
}
|
| 235 |
+
}
|
| 236 |
+
]
|
| 237 |
+
}
|
| 238 |
+
},
|
| 239 |
+
"PrivateSubnet2": {
|
| 240 |
+
"Type": "AWS::EC2::Subnet",
|
| 241 |
+
"Properties": {
|
| 242 |
+
"VpcId": {
|
| 243 |
+
"Ref": "VPC"
|
| 244 |
+
},
|
| 245 |
+
"AvailabilityZone": {
|
| 246 |
+
"Fn::Select": [
|
| 247 |
+
1,
|
| 248 |
+
{
|
| 249 |
+
"Fn::GetAZs": null
|
| 250 |
+
}
|
| 251 |
+
]
|
| 252 |
+
},
|
| 253 |
+
"CidrBlock": {
|
| 254 |
+
"Ref": "PrivateSubnet2CIDR"
|
| 255 |
+
},
|
| 256 |
+
"MapPublicIpOnLaunch": false,
|
| 257 |
+
"Tags": [
|
| 258 |
+
{
|
| 259 |
+
"Key": "Name",
|
| 260 |
+
"Value": {
|
| 261 |
+
"Fn::Sub": "${EnvironmentName} Private Subnet (AZ2)"
|
| 262 |
+
}
|
| 263 |
+
}
|
| 264 |
+
]
|
| 265 |
+
}
|
| 266 |
+
},
|
| 267 |
+
"PublicRouteTable": {
|
| 268 |
+
"Type": "AWS::EC2::RouteTable",
|
| 269 |
+
"Properties": {
|
| 270 |
+
"VpcId": {
|
| 271 |
+
"Ref": "VPC"
|
| 272 |
+
},
|
| 273 |
+
"Tags": [
|
| 274 |
+
{
|
| 275 |
+
"Key": "Name",
|
| 276 |
+
"Value": {
|
| 277 |
+
"Fn::Sub": "${EnvironmentName} Public Routes"
|
| 278 |
+
}
|
| 279 |
+
}
|
| 280 |
+
]
|
| 281 |
+
}
|
| 282 |
+
},
|
| 283 |
+
"DefaultPublicRoute": {
|
| 284 |
+
"Type": "AWS::EC2::Route",
|
| 285 |
+
"DependsOn": "InternetGatewayAttachment",
|
| 286 |
+
"Properties": {
|
| 287 |
+
"RouteTableId": {
|
| 288 |
+
"Ref": "PublicRouteTable"
|
| 289 |
+
},
|
| 290 |
+
"DestinationCidrBlock": "0.0.0.0/0",
|
| 291 |
+
"GatewayId": {
|
| 292 |
+
"Ref": "InternetGateway"
|
| 293 |
+
}
|
| 294 |
+
}
|
| 295 |
+
},
|
| 296 |
+
"PublicSubnet1RouteTableAssociation": {
|
| 297 |
+
"Type": "AWS::EC2::SubnetRouteTableAssociation",
|
| 298 |
+
"Properties": {
|
| 299 |
+
"RouteTableId": {
|
| 300 |
+
"Ref": "PublicRouteTable"
|
| 301 |
+
},
|
| 302 |
+
"SubnetId": {
|
| 303 |
+
"Ref": "PublicSubnet1"
|
| 304 |
+
}
|
| 305 |
+
}
|
| 306 |
+
},
|
| 307 |
+
"PublicSubnet2RouteTableAssociation": {
|
| 308 |
+
"Type": "AWS::EC2::SubnetRouteTableAssociation",
|
| 309 |
+
"Properties": {
|
| 310 |
+
"RouteTableId": {
|
| 311 |
+
"Ref": "PublicRouteTable"
|
| 312 |
+
},
|
| 313 |
+
"SubnetId": {
|
| 314 |
+
"Ref": "PublicSubnet2"
|
| 315 |
+
}
|
| 316 |
+
}
|
| 317 |
+
},
|
| 318 |
+
"PrivateRouteTable1": {
|
| 319 |
+
"Type": "AWS::EC2::RouteTable",
|
| 320 |
+
"Properties": {
|
| 321 |
+
"VpcId": {
|
| 322 |
+
"Ref": "VPC"
|
| 323 |
+
},
|
| 324 |
+
"Tags": [
|
| 325 |
+
{
|
| 326 |
+
"Key": "Name",
|
| 327 |
+
"Value": {
|
| 328 |
+
"Fn::Sub": "${EnvironmentName} Private Routes (AZ1)"
|
| 329 |
+
}
|
| 330 |
+
}
|
| 331 |
+
]
|
| 332 |
+
}
|
| 333 |
+
},
|
| 334 |
+
"PrivateSubnet1RouteTableAssociation": {
|
| 335 |
+
"Type": "AWS::EC2::SubnetRouteTableAssociation",
|
| 336 |
+
"Properties": {
|
| 337 |
+
"RouteTableId": {
|
| 338 |
+
"Ref": "PrivateRouteTable1"
|
| 339 |
+
},
|
| 340 |
+
"SubnetId": {
|
| 341 |
+
"Ref": "PrivateSubnet1"
|
| 342 |
+
}
|
| 343 |
+
}
|
| 344 |
+
},
|
| 345 |
+
"PrivateRouteTable2": {
|
| 346 |
+
"Type": "AWS::EC2::RouteTable",
|
| 347 |
+
"Properties": {
|
| 348 |
+
"VpcId": {
|
| 349 |
+
"Ref": "VPC"
|
| 350 |
+
},
|
| 351 |
+
"Tags": [
|
| 352 |
+
{
|
| 353 |
+
"Key": "Name",
|
| 354 |
+
"Value": {
|
| 355 |
+
"Fn::Sub": "${EnvironmentName} Private Routes (AZ2)"
|
| 356 |
+
}
|
| 357 |
+
}
|
| 358 |
+
]
|
| 359 |
+
}
|
| 360 |
+
},
|
| 361 |
+
"PrivateSubnet2RouteTableAssociation": {
|
| 362 |
+
"Type": "AWS::EC2::SubnetRouteTableAssociation",
|
| 363 |
+
"Properties": {
|
| 364 |
+
"RouteTableId": {
|
| 365 |
+
"Ref": "PrivateRouteTable2"
|
| 366 |
+
},
|
| 367 |
+
"SubnetId": {
|
| 368 |
+
"Ref": "PrivateSubnet2"
|
| 369 |
+
}
|
| 370 |
+
}
|
| 371 |
+
},
|
| 372 |
+
"RootRole": {
|
| 373 |
+
"Type": "AWS::IAM::Role",
|
| 374 |
+
"Properties": {
|
| 375 |
+
"AssumeRolePolicyDocument": {
|
| 376 |
+
"Version": "2012-10-17",
|
| 377 |
+
"Statement": [
|
| 378 |
+
{
|
| 379 |
+
"Effect": "Allow",
|
| 380 |
+
"Principal": {
|
| 381 |
+
"Service": [
|
| 382 |
+
"ec2.amazonaws.com"
|
| 383 |
+
]
|
| 384 |
+
},
|
| 385 |
+
"Action": [
|
| 386 |
+
"sts:AssumeRole"
|
| 387 |
+
]
|
| 388 |
+
}
|
| 389 |
+
]
|
| 390 |
+
},
|
| 391 |
+
"Path": "/",
|
| 392 |
+
"Policies": [
|
| 393 |
+
{
|
| 394 |
+
"PolicyName": "root",
|
| 395 |
+
"PolicyDocument": {
|
| 396 |
+
"Version": "2012-10-17",
|
| 397 |
+
"Statement": [
|
| 398 |
+
{
|
| 399 |
+
"Effect": "Allow",
|
| 400 |
+
"Action": "cloudformation:*",
|
| 401 |
+
"Resource": "*"
|
| 402 |
+
}
|
| 403 |
+
]
|
| 404 |
+
}
|
| 405 |
+
}
|
| 406 |
+
]
|
| 407 |
+
}
|
| 408 |
+
},
|
| 409 |
+
"BastionInstance": {
|
| 410 |
+
"Type": "AWS::EC2::Instance",
|
| 411 |
+
"Properties": {
|
| 412 |
+
"KeyName": {
|
| 413 |
+
"Ref": "KeyName"
|
| 414 |
+
},
|
| 415 |
+
"InstanceType": "t2.micro",
|
| 416 |
+
"SecurityGroupIds": [
|
| 417 |
+
{
|
| 418 |
+
"Ref": "BastionSG"
|
| 419 |
+
}
|
| 420 |
+
],
|
| 421 |
+
"SubnetId": {
|
| 422 |
+
"Ref": "PublicSubnet1"
|
| 423 |
+
},
|
| 424 |
+
"ImageId": {
|
| 425 |
+
"Ref": "LinuxAMI"
|
| 426 |
+
},
|
| 427 |
+
"IamInstanceProfile": {
|
| 428 |
+
"Ref": "BastionProfile"
|
| 429 |
+
},
|
| 430 |
+
"Tags": [
|
| 431 |
+
{
|
| 432 |
+
"Key": "Name",
|
| 433 |
+
"Value": "Bastion"
|
| 434 |
+
}
|
| 435 |
+
]
|
| 436 |
+
}
|
| 437 |
+
},
|
| 438 |
+
"BastionSG": {
|
| 439 |
+
"Type": "AWS::EC2::SecurityGroup",
|
| 440 |
+
"Metadata": {
|
| 441 |
+
"guard": {
|
| 442 |
+
"SuppressedRules": [
|
| 443 |
+
"INCOMING_SSH_DISABLED"
|
| 444 |
+
]
|
| 445 |
+
}
|
| 446 |
+
},
|
| 447 |
+
"Properties": {
|
| 448 |
+
"GroupDescription": "Inbound Bastion Traffic",
|
| 449 |
+
"SecurityGroupIngress": [
|
| 450 |
+
{
|
| 451 |
+
"IpProtocol": "tcp",
|
| 452 |
+
"FromPort": 22,
|
| 453 |
+
"ToPort": 22,
|
| 454 |
+
"CidrIp": "0.0.0.0/0"
|
| 455 |
+
}
|
| 456 |
+
],
|
| 457 |
+
"VpcId": {
|
| 458 |
+
"Ref": "VPC"
|
| 459 |
+
},
|
| 460 |
+
"Tags": [
|
| 461 |
+
{
|
| 462 |
+
"Key": "Name",
|
| 463 |
+
"Value": "BastionSG"
|
| 464 |
+
}
|
| 465 |
+
]
|
| 466 |
+
}
|
| 467 |
+
},
|
| 468 |
+
"BastionProfile": {
|
| 469 |
+
"Type": "AWS::IAM::InstanceProfile",
|
| 470 |
+
"Properties": {
|
| 471 |
+
"Path": "/",
|
| 472 |
+
"Roles": [
|
| 473 |
+
{
|
| 474 |
+
"Ref": "RootRole"
|
| 475 |
+
}
|
| 476 |
+
]
|
| 477 |
+
}
|
| 478 |
+
},
|
| 479 |
+
"PrivateInstance": {
|
| 480 |
+
"Type": "AWS::EC2::Instance",
|
| 481 |
+
"DependsOn": "CfnEndpoint",
|
| 482 |
+
"Properties": {
|
| 483 |
+
"KeyName": {
|
| 484 |
+
"Ref": "KeyName"
|
| 485 |
+
},
|
| 486 |
+
"InstanceType": "t2.micro",
|
| 487 |
+
"SecurityGroupIds": [
|
| 488 |
+
{
|
| 489 |
+
"Ref": "PrivateSG"
|
| 490 |
+
}
|
| 491 |
+
],
|
| 492 |
+
"SubnetId": {
|
| 493 |
+
"Ref": "PrivateSubnet1"
|
| 494 |
+
},
|
| 495 |
+
"ImageId": {
|
| 496 |
+
"Ref": "LinuxAMI"
|
| 497 |
+
},
|
| 498 |
+
"IamInstanceProfile": {
|
| 499 |
+
"Ref": "PrivateProfile"
|
| 500 |
+
},
|
| 501 |
+
"UserData": {
|
| 502 |
+
"Fn::Base64": {
|
| 503 |
+
"Fn::Sub": "#!/bin/bash -x\ndate > /tmp/datefile\ncat /tmp/datefile\n# Signal the status from instance\n/opt/aws/bin/cfn-signal -e $? -d \"This was all private.\" -r \"Build Process Complete\" '${PrivateWaitHandle}'\n"
|
| 504 |
+
}
|
| 505 |
+
},
|
| 506 |
+
"Tags": [
|
| 507 |
+
{
|
| 508 |
+
"Key": "Name",
|
| 509 |
+
"Value": "Private"
|
| 510 |
+
}
|
| 511 |
+
]
|
| 512 |
+
}
|
| 513 |
+
},
|
| 514 |
+
"PrivateSG": {
|
| 515 |
+
"Type": "AWS::EC2::SecurityGroup",
|
| 516 |
+
"Properties": {
|
| 517 |
+
"GroupDescription": "Traffic from Bastion",
|
| 518 |
+
"SecurityGroupIngress": [
|
| 519 |
+
{
|
| 520 |
+
"IpProtocol": "tcp",
|
| 521 |
+
"FromPort": 22,
|
| 522 |
+
"ToPort": 22,
|
| 523 |
+
"SourceSecurityGroupId": {
|
| 524 |
+
"Ref": "BastionSG"
|
| 525 |
+
}
|
| 526 |
+
}
|
| 527 |
+
],
|
| 528 |
+
"VpcId": {
|
| 529 |
+
"Ref": "VPC"
|
| 530 |
+
},
|
| 531 |
+
"Tags": [
|
| 532 |
+
{
|
| 533 |
+
"Key": "Name",
|
| 534 |
+
"Value": "PrivateSG"
|
| 535 |
+
}
|
| 536 |
+
]
|
| 537 |
+
}
|
| 538 |
+
},
|
| 539 |
+
"PrivateProfile": {
|
| 540 |
+
"Type": "AWS::IAM::InstanceProfile",
|
| 541 |
+
"Properties": {
|
| 542 |
+
"Path": "/",
|
| 543 |
+
"Roles": [
|
| 544 |
+
{
|
| 545 |
+
"Ref": "RootRole"
|
| 546 |
+
}
|
| 547 |
+
]
|
| 548 |
+
}
|
| 549 |
+
},
|
| 550 |
+
"EndpointSG": {
|
| 551 |
+
"Type": "AWS::EC2::SecurityGroup",
|
| 552 |
+
"Properties": {
|
| 553 |
+
"GroupDescription": "Traffic into CloudFormation Endpoint",
|
| 554 |
+
"SecurityGroupIngress": [
|
| 555 |
+
{
|
| 556 |
+
"IpProtocol": "tcp",
|
| 557 |
+
"FromPort": 443,
|
| 558 |
+
"ToPort": 443,
|
| 559 |
+
"CidrIp": "0.0.0.0/0"
|
| 560 |
+
}
|
| 561 |
+
],
|
| 562 |
+
"VpcId": {
|
| 563 |
+
"Ref": "VPC"
|
| 564 |
+
},
|
| 565 |
+
"Tags": [
|
| 566 |
+
{
|
| 567 |
+
"Key": "Name",
|
| 568 |
+
"Value": "EndpointSG"
|
| 569 |
+
}
|
| 570 |
+
]
|
| 571 |
+
}
|
| 572 |
+
},
|
| 573 |
+
"PrivateWaitHandle": {
|
| 574 |
+
"Type": "AWS::CloudFormation::WaitConditionHandle"
|
| 575 |
+
},
|
| 576 |
+
"PrivateWaitCondition": {
|
| 577 |
+
"Type": "AWS::CloudFormation::WaitCondition",
|
| 578 |
+
"DependsOn": "PrivateInstance",
|
| 579 |
+
"Properties": {
|
| 580 |
+
"Handle": {
|
| 581 |
+
"Ref": "PrivateWaitHandle"
|
| 582 |
+
},
|
| 583 |
+
"Timeout": "3600",
|
| 584 |
+
"Count": 1
|
| 585 |
+
}
|
| 586 |
+
}
|
| 587 |
+
},
|
| 588 |
+
"Outputs": {
|
| 589 |
+
"VPC": {
|
| 590 |
+
"Description": "A reference to the created VPC",
|
| 591 |
+
"Value": {
|
| 592 |
+
"Ref": "VPC"
|
| 593 |
+
}
|
| 594 |
+
},
|
| 595 |
+
"PublicSubnets": {
|
| 596 |
+
"Description": "A list of the public subnets",
|
| 597 |
+
"Value": {
|
| 598 |
+
"Fn::Join": [
|
| 599 |
+
",",
|
| 600 |
+
[
|
| 601 |
+
{
|
| 602 |
+
"Ref": "PublicSubnet1"
|
| 603 |
+
},
|
| 604 |
+
{
|
| 605 |
+
"Ref": "PublicSubnet2"
|
| 606 |
+
}
|
| 607 |
+
]
|
| 608 |
+
]
|
| 609 |
+
}
|
| 610 |
+
},
|
| 611 |
+
"PrivateSubnets": {
|
| 612 |
+
"Description": "A list of the private subnets",
|
| 613 |
+
"Value": {
|
| 614 |
+
"Fn::Join": [
|
| 615 |
+
",",
|
| 616 |
+
[
|
| 617 |
+
{
|
| 618 |
+
"Ref": "PrivateSubnet1"
|
| 619 |
+
},
|
| 620 |
+
{
|
| 621 |
+
"Ref": "PrivateSubnet2"
|
| 622 |
+
}
|
| 623 |
+
]
|
| 624 |
+
]
|
| 625 |
+
}
|
| 626 |
+
},
|
| 627 |
+
"CfnEndpoint": {
|
| 628 |
+
"Description": "A reference to the CloudFormation Endpoint used for signaling from the private instance",
|
| 629 |
+
"Value": {
|
| 630 |
+
"Ref": "CfnEndpoint"
|
| 631 |
+
}
|
| 632 |
+
},
|
| 633 |
+
"S3Endpoint": {
|
| 634 |
+
"Description": "A reference to the S3 Endpoint used for signaling from the private instance",
|
| 635 |
+
"Value": {
|
| 636 |
+
"Ref": "S3Endpoint"
|
| 637 |
+
}
|
| 638 |
+
}
|
| 639 |
+
}
|
| 640 |
+
}
|
human_reference_dataset/aws-cloudformation-templates/Solutions/CloudFormationEndpointSignals/cfn-endpoint-waitcondition.yaml
ADDED
|
@@ -0,0 +1,373 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
AWSTemplateFormatVersion: "2010-09-09"
|
| 2 |
+
|
| 3 |
+
Description: |
|
| 4 |
+
This template deploys a VPC with a pair of public and private subnets spread across two Availabilty Zones. It deploys an Internet Gateway, with a default route on the public subnets and a bastion server. It deploys VPC Endpoints for CloudFormation and S3 so an instance in the private subnet can use cfn-signal for a WaitCondition. **WARNING** You will be billed for the AWS resources used if you create a stack from this template.
|
| 5 |
+
|
| 6 |
+
Parameters:
|
| 7 |
+
EnvironmentName:
|
| 8 |
+
Description: An environment name that will be prefixed to resource names
|
| 9 |
+
Type: String
|
| 10 |
+
|
| 11 |
+
VpcCIDR:
|
| 12 |
+
Description: Please enter the IP range (CIDR notation) for this VPC
|
| 13 |
+
Type: String
|
| 14 |
+
Default: 10.192.0.0/16
|
| 15 |
+
AllowedPattern: ((\d{1,3})\.){3}\d{1,3}/\d{1,2}
|
| 16 |
+
|
| 17 |
+
PublicSubnet1CIDR:
|
| 18 |
+
Description: Please enter the IP range (CIDR notation) for the public subnet in the first Availability Zone
|
| 19 |
+
Type: String
|
| 20 |
+
Default: 10.192.10.0/24
|
| 21 |
+
AllowedPattern: ((\d{1,3})\.){3}\d{1,3}/\d{1,2}
|
| 22 |
+
|
| 23 |
+
PublicSubnet2CIDR:
|
| 24 |
+
Description: Please enter the IP range (CIDR notation) for the public subnet in the second Availability Zone
|
| 25 |
+
Type: String
|
| 26 |
+
Default: 10.192.11.0/24
|
| 27 |
+
AllowedPattern: ((\d{1,3})\.){3}\d{1,3}/\d{1,2}
|
| 28 |
+
|
| 29 |
+
PrivateSubnet1CIDR:
|
| 30 |
+
Description: Please enter the IP range (CIDR notation) for the private subnet in the first Availability Zone
|
| 31 |
+
Type: String
|
| 32 |
+
Default: 10.192.20.0/24
|
| 33 |
+
AllowedPattern: ((\d{1,3})\.){3}\d{1,3}/\d{1,2}
|
| 34 |
+
|
| 35 |
+
PrivateSubnet2CIDR:
|
| 36 |
+
Description: Please enter the IP range (CIDR notation) for the private subnet in the second Availability Zone
|
| 37 |
+
Type: String
|
| 38 |
+
Default: 10.192.21.0/24
|
| 39 |
+
AllowedPattern: ((\d{1,3})\.){3}\d{1,3}/\d{1,2}
|
| 40 |
+
|
| 41 |
+
KeyName:
|
| 42 |
+
Description: Key pair for EC2 access
|
| 43 |
+
Type: AWS::EC2::KeyPair::KeyName
|
| 44 |
+
|
| 45 |
+
LinuxAMI:
|
| 46 |
+
Description: Managed AMI ID for Amazon Linux
|
| 47 |
+
Type: AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>
|
| 48 |
+
Default: /aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-gp2
|
| 49 |
+
|
| 50 |
+
Resources:
|
| 51 |
+
VPC:
|
| 52 |
+
Type: AWS::EC2::VPC
|
| 53 |
+
Properties:
|
| 54 |
+
EnableDnsSupport: true
|
| 55 |
+
EnableDnsHostnames: true
|
| 56 |
+
CidrBlock: !Ref VpcCIDR
|
| 57 |
+
Tags:
|
| 58 |
+
- Key: Name
|
| 59 |
+
Value: !Ref EnvironmentName
|
| 60 |
+
|
| 61 |
+
InternetGateway:
|
| 62 |
+
Type: AWS::EC2::InternetGateway
|
| 63 |
+
Properties:
|
| 64 |
+
Tags:
|
| 65 |
+
- Key: Name
|
| 66 |
+
Value: !Ref EnvironmentName
|
| 67 |
+
|
| 68 |
+
InternetGatewayAttachment:
|
| 69 |
+
Type: AWS::EC2::VPCGatewayAttachment
|
| 70 |
+
Properties:
|
| 71 |
+
InternetGatewayId: !Ref InternetGateway
|
| 72 |
+
VpcId: !Ref VPC
|
| 73 |
+
|
| 74 |
+
# This is the interface endpoint for CloudFormation. You can only deploy this
|
| 75 |
+
# once per region since it will consume the unique DNS entry for the endpoint.
|
| 76 |
+
CfnEndpoint:
|
| 77 |
+
Type: AWS::EC2::VPCEndpoint
|
| 78 |
+
Properties:
|
| 79 |
+
VpcId: !Ref VPC
|
| 80 |
+
ServiceName: !Sub com.amazonaws.${AWS::Region}.cloudformation
|
| 81 |
+
VpcEndpointType: Interface
|
| 82 |
+
PrivateDnsEnabled: true
|
| 83 |
+
SubnetIds:
|
| 84 |
+
- !Ref PrivateSubnet1
|
| 85 |
+
- !Ref PrivateSubnet2
|
| 86 |
+
SecurityGroupIds:
|
| 87 |
+
- !Ref EndpointSG
|
| 88 |
+
|
| 89 |
+
# This is the gateway endpoint for S3. WaitConditions and CustomResources
|
| 90 |
+
# need to access self-signed URLs in the following buckets to signal back
|
| 91 |
+
# to the stack.
|
| 92 |
+
S3Endpoint:
|
| 93 |
+
Type: AWS::EC2::VPCEndpoint
|
| 94 |
+
Properties:
|
| 95 |
+
VpcId: !Ref VPC
|
| 96 |
+
ServiceName: !Sub com.amazonaws.${AWS::Region}.s3
|
| 97 |
+
VpcEndpointType: Gateway
|
| 98 |
+
PolicyDocument:
|
| 99 |
+
Version: "2012-10-17"
|
| 100 |
+
Statement:
|
| 101 |
+
- Effect: Allow
|
| 102 |
+
Principal: '*'
|
| 103 |
+
Action:
|
| 104 |
+
- s3:PutObject
|
| 105 |
+
Resource:
|
| 106 |
+
- !Sub arn:${AWS::Partition}:s3:::cloudformation-waitcondition-${AWS::Region}/*
|
| 107 |
+
RouteTableIds:
|
| 108 |
+
- !Ref PrivateRouteTable1
|
| 109 |
+
- !Ref PrivateRouteTable2
|
| 110 |
+
|
| 111 |
+
PublicSubnet1:
|
| 112 |
+
Type: AWS::EC2::Subnet
|
| 113 |
+
Properties:
|
| 114 |
+
VpcId: !Ref VPC
|
| 115 |
+
AvailabilityZone: !Select
|
| 116 |
+
- 0
|
| 117 |
+
- !GetAZs
|
| 118 |
+
CidrBlock: !Ref PublicSubnet1CIDR
|
| 119 |
+
MapPublicIpOnLaunch: true
|
| 120 |
+
Tags:
|
| 121 |
+
- Key: Name
|
| 122 |
+
Value: !Sub ${EnvironmentName} Public Subnet (AZ1)
|
| 123 |
+
|
| 124 |
+
PublicSubnet2:
|
| 125 |
+
Type: AWS::EC2::Subnet
|
| 126 |
+
Properties:
|
| 127 |
+
VpcId: !Ref VPC
|
| 128 |
+
AvailabilityZone: !Select
|
| 129 |
+
- 1
|
| 130 |
+
- !GetAZs
|
| 131 |
+
CidrBlock: !Ref PublicSubnet2CIDR
|
| 132 |
+
MapPublicIpOnLaunch: true
|
| 133 |
+
Tags:
|
| 134 |
+
- Key: Name
|
| 135 |
+
Value: !Sub ${EnvironmentName} Public Subnet (AZ2)
|
| 136 |
+
|
| 137 |
+
PrivateSubnet1:
|
| 138 |
+
Type: AWS::EC2::Subnet
|
| 139 |
+
Properties:
|
| 140 |
+
VpcId: !Ref VPC
|
| 141 |
+
AvailabilityZone: !Select
|
| 142 |
+
- 0
|
| 143 |
+
- !GetAZs
|
| 144 |
+
CidrBlock: !Ref PrivateSubnet1CIDR
|
| 145 |
+
MapPublicIpOnLaunch: false
|
| 146 |
+
Tags:
|
| 147 |
+
- Key: Name
|
| 148 |
+
Value: !Sub ${EnvironmentName} Private Subnet (AZ1)
|
| 149 |
+
|
| 150 |
+
PrivateSubnet2:
|
| 151 |
+
Type: AWS::EC2::Subnet
|
| 152 |
+
Properties:
|
| 153 |
+
VpcId: !Ref VPC
|
| 154 |
+
AvailabilityZone: !Select
|
| 155 |
+
- 1
|
| 156 |
+
- !GetAZs
|
| 157 |
+
CidrBlock: !Ref PrivateSubnet2CIDR
|
| 158 |
+
MapPublicIpOnLaunch: false
|
| 159 |
+
Tags:
|
| 160 |
+
- Key: Name
|
| 161 |
+
Value: !Sub ${EnvironmentName} Private Subnet (AZ2)
|
| 162 |
+
|
| 163 |
+
PublicRouteTable:
|
| 164 |
+
Type: AWS::EC2::RouteTable
|
| 165 |
+
Properties:
|
| 166 |
+
VpcId: !Ref VPC
|
| 167 |
+
Tags:
|
| 168 |
+
- Key: Name
|
| 169 |
+
Value: !Sub ${EnvironmentName} Public Routes
|
| 170 |
+
|
| 171 |
+
DefaultPublicRoute:
|
| 172 |
+
Type: AWS::EC2::Route
|
| 173 |
+
DependsOn: InternetGatewayAttachment
|
| 174 |
+
Properties:
|
| 175 |
+
RouteTableId: !Ref PublicRouteTable
|
| 176 |
+
DestinationCidrBlock: 0.0.0.0/0
|
| 177 |
+
GatewayId: !Ref InternetGateway
|
| 178 |
+
|
| 179 |
+
PublicSubnet1RouteTableAssociation:
|
| 180 |
+
Type: AWS::EC2::SubnetRouteTableAssociation
|
| 181 |
+
Properties:
|
| 182 |
+
RouteTableId: !Ref PublicRouteTable
|
| 183 |
+
SubnetId: !Ref PublicSubnet1
|
| 184 |
+
|
| 185 |
+
PublicSubnet2RouteTableAssociation:
|
| 186 |
+
Type: AWS::EC2::SubnetRouteTableAssociation
|
| 187 |
+
Properties:
|
| 188 |
+
RouteTableId: !Ref PublicRouteTable
|
| 189 |
+
SubnetId: !Ref PublicSubnet2
|
| 190 |
+
|
| 191 |
+
PrivateRouteTable1:
|
| 192 |
+
Type: AWS::EC2::RouteTable
|
| 193 |
+
Properties:
|
| 194 |
+
VpcId: !Ref VPC
|
| 195 |
+
Tags:
|
| 196 |
+
- Key: Name
|
| 197 |
+
Value: !Sub ${EnvironmentName} Private Routes (AZ1)
|
| 198 |
+
|
| 199 |
+
PrivateSubnet1RouteTableAssociation:
|
| 200 |
+
Type: AWS::EC2::SubnetRouteTableAssociation
|
| 201 |
+
Properties:
|
| 202 |
+
RouteTableId: !Ref PrivateRouteTable1
|
| 203 |
+
SubnetId: !Ref PrivateSubnet1
|
| 204 |
+
|
| 205 |
+
PrivateRouteTable2:
|
| 206 |
+
Type: AWS::EC2::RouteTable
|
| 207 |
+
Properties:
|
| 208 |
+
VpcId: !Ref VPC
|
| 209 |
+
Tags:
|
| 210 |
+
- Key: Name
|
| 211 |
+
Value: !Sub ${EnvironmentName} Private Routes (AZ2)
|
| 212 |
+
|
| 213 |
+
PrivateSubnet2RouteTableAssociation:
|
| 214 |
+
Type: AWS::EC2::SubnetRouteTableAssociation
|
| 215 |
+
Properties:
|
| 216 |
+
RouteTableId: !Ref PrivateRouteTable2
|
| 217 |
+
SubnetId: !Ref PrivateSubnet2
|
| 218 |
+
|
| 219 |
+
RootRole:
|
| 220 |
+
Type: AWS::IAM::Role
|
| 221 |
+
Properties:
|
| 222 |
+
AssumeRolePolicyDocument:
|
| 223 |
+
Version: "2012-10-17"
|
| 224 |
+
Statement:
|
| 225 |
+
- Effect: Allow
|
| 226 |
+
Principal:
|
| 227 |
+
Service:
|
| 228 |
+
- ec2.amazonaws.com
|
| 229 |
+
Action:
|
| 230 |
+
- sts:AssumeRole
|
| 231 |
+
Path: /
|
| 232 |
+
Policies:
|
| 233 |
+
- PolicyName: root
|
| 234 |
+
PolicyDocument:
|
| 235 |
+
Version: "2012-10-17"
|
| 236 |
+
Statement:
|
| 237 |
+
- Effect: Allow
|
| 238 |
+
Action: cloudformation:*
|
| 239 |
+
Resource: '*'
|
| 240 |
+
|
| 241 |
+
BastionInstance:
|
| 242 |
+
Type: AWS::EC2::Instance
|
| 243 |
+
Properties:
|
| 244 |
+
KeyName: !Ref KeyName
|
| 245 |
+
InstanceType: t2.micro
|
| 246 |
+
SecurityGroupIds:
|
| 247 |
+
- !Ref BastionSG
|
| 248 |
+
SubnetId: !Ref PublicSubnet1
|
| 249 |
+
ImageId: !Ref LinuxAMI
|
| 250 |
+
IamInstanceProfile: !Ref BastionProfile
|
| 251 |
+
Tags:
|
| 252 |
+
- Key: Name
|
| 253 |
+
Value: Bastion
|
| 254 |
+
|
| 255 |
+
BastionSG:
|
| 256 |
+
Type: AWS::EC2::SecurityGroup
|
| 257 |
+
Metadata:
|
| 258 |
+
guard:
|
| 259 |
+
SuppressedRules:
|
| 260 |
+
- INCOMING_SSH_DISABLED
|
| 261 |
+
Properties:
|
| 262 |
+
GroupDescription: Inbound Bastion Traffic
|
| 263 |
+
SecurityGroupIngress:
|
| 264 |
+
- IpProtocol: tcp
|
| 265 |
+
FromPort: 22
|
| 266 |
+
ToPort: 22
|
| 267 |
+
CidrIp: 0.0.0.0/0
|
| 268 |
+
VpcId: !Ref VPC
|
| 269 |
+
Tags:
|
| 270 |
+
- Key: Name
|
| 271 |
+
Value: BastionSG
|
| 272 |
+
|
| 273 |
+
BastionProfile:
|
| 274 |
+
Type: AWS::IAM::InstanceProfile
|
| 275 |
+
Properties:
|
| 276 |
+
Path: /
|
| 277 |
+
Roles:
|
| 278 |
+
- !Ref RootRole
|
| 279 |
+
|
| 280 |
+
PrivateInstance:
|
| 281 |
+
Type: AWS::EC2::Instance
|
| 282 |
+
DependsOn: CfnEndpoint
|
| 283 |
+
Properties:
|
| 284 |
+
KeyName: !Ref KeyName
|
| 285 |
+
InstanceType: t2.micro
|
| 286 |
+
SecurityGroupIds:
|
| 287 |
+
- !Ref PrivateSG
|
| 288 |
+
SubnetId: !Ref PrivateSubnet1
|
| 289 |
+
ImageId: !Ref LinuxAMI
|
| 290 |
+
IamInstanceProfile: !Ref PrivateProfile
|
| 291 |
+
UserData: !Base64
|
| 292 |
+
Fn::Sub: |
|
| 293 |
+
#!/bin/bash -x
|
| 294 |
+
date > /tmp/datefile
|
| 295 |
+
cat /tmp/datefile
|
| 296 |
+
# Signal the status from instance
|
| 297 |
+
/opt/aws/bin/cfn-signal -e $? -d "This was all private." -r "Build Process Complete" '${PrivateWaitHandle}'
|
| 298 |
+
Tags:
|
| 299 |
+
- Key: Name
|
| 300 |
+
Value: Private
|
| 301 |
+
|
| 302 |
+
PrivateSG:
|
| 303 |
+
Type: AWS::EC2::SecurityGroup
|
| 304 |
+
Properties:
|
| 305 |
+
GroupDescription: Traffic from Bastion
|
| 306 |
+
SecurityGroupIngress:
|
| 307 |
+
- IpProtocol: tcp
|
| 308 |
+
FromPort: 22
|
| 309 |
+
ToPort: 22
|
| 310 |
+
SourceSecurityGroupId: !Ref BastionSG
|
| 311 |
+
VpcId: !Ref VPC
|
| 312 |
+
Tags:
|
| 313 |
+
- Key: Name
|
| 314 |
+
Value: PrivateSG
|
| 315 |
+
|
| 316 |
+
PrivateProfile:
|
| 317 |
+
Type: AWS::IAM::InstanceProfile
|
| 318 |
+
Properties:
|
| 319 |
+
Path: /
|
| 320 |
+
Roles:
|
| 321 |
+
- !Ref RootRole
|
| 322 |
+
|
| 323 |
+
EndpointSG:
|
| 324 |
+
Type: AWS::EC2::SecurityGroup
|
| 325 |
+
Properties:
|
| 326 |
+
GroupDescription: Traffic into CloudFormation Endpoint
|
| 327 |
+
SecurityGroupIngress:
|
| 328 |
+
- IpProtocol: tcp
|
| 329 |
+
FromPort: 443
|
| 330 |
+
ToPort: 443
|
| 331 |
+
CidrIp: 0.0.0.0/0
|
| 332 |
+
VpcId: !Ref VPC
|
| 333 |
+
Tags:
|
| 334 |
+
- Key: Name
|
| 335 |
+
Value: EndpointSG
|
| 336 |
+
|
| 337 |
+
PrivateWaitHandle:
|
| 338 |
+
Type: AWS::CloudFormation::WaitConditionHandle
|
| 339 |
+
|
| 340 |
+
PrivateWaitCondition:
|
| 341 |
+
Type: AWS::CloudFormation::WaitCondition
|
| 342 |
+
DependsOn: PrivateInstance
|
| 343 |
+
Properties:
|
| 344 |
+
Handle: !Ref PrivateWaitHandle
|
| 345 |
+
Timeout: "3600"
|
| 346 |
+
Count: 1
|
| 347 |
+
|
| 348 |
+
Outputs:
|
| 349 |
+
VPC:
|
| 350 |
+
Description: A reference to the created VPC
|
| 351 |
+
Value: !Ref VPC
|
| 352 |
+
|
| 353 |
+
PublicSubnets:
|
| 354 |
+
Description: A list of the public subnets
|
| 355 |
+
Value: !Join
|
| 356 |
+
- ','
|
| 357 |
+
- - !Ref PublicSubnet1
|
| 358 |
+
- !Ref PublicSubnet2
|
| 359 |
+
|
| 360 |
+
PrivateSubnets:
|
| 361 |
+
Description: A list of the private subnets
|
| 362 |
+
Value: !Join
|
| 363 |
+
- ','
|
| 364 |
+
- - !Ref PrivateSubnet1
|
| 365 |
+
- !Ref PrivateSubnet2
|
| 366 |
+
|
| 367 |
+
CfnEndpoint:
|
| 368 |
+
Description: A reference to the CloudFormation Endpoint used for signaling from the private instance
|
| 369 |
+
Value: !Ref CfnEndpoint
|
| 370 |
+
|
| 371 |
+
S3Endpoint:
|
| 372 |
+
Description: A reference to the S3 Endpoint used for signaling from the private instance
|
| 373 |
+
Value: !Ref S3Endpoint
|
human_reference_dataset/aws-cloudformation-templates/Solutions/CloudFrontCustomOriginLambda@Edge/CloudFront.json
ADDED
|
@@ -0,0 +1,1227 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"AWSTemplateFormatVersion": "2010-09-09",
|
| 3 |
+
"Description": "CI/CD optimized AWS CloudFormation Sample Template for AWS CloudFront Distribution with Custom Origin with an example of using the AWS Application Load Balancer (ALB) and a basic Amazon EC2 Instance. AWS CloudFront Distribution is associated with Lambda@Edge for Security Headers inspection. In addition, AWS CloudFormation Template will provision an Examples of necessary IAM, S3, KMS and Security Groups resources. ### Before deployment please make sure that all parameters are reviewed and updated according the specific use case. ### **WARNING** This template creates one Amazon EC2 instance and an Application Load Balancer, KMS Keys, S3 bucket, CloudFront Distribution resources. You will be billed for the AWS resources used if you create a stack from this template.",
|
| 4 |
+
"Metadata": {
|
| 5 |
+
"cfn-lint": {
|
| 6 |
+
"config": {
|
| 7 |
+
"regions": [
|
| 8 |
+
"us-east-1",
|
| 9 |
+
"us-west-2"
|
| 10 |
+
]
|
| 11 |
+
}
|
| 12 |
+
}
|
| 13 |
+
},
|
| 14 |
+
"Parameters": {
|
| 15 |
+
"Environment": {
|
| 16 |
+
"Description": "Please specify the target environment.",
|
| 17 |
+
"Type": "String",
|
| 18 |
+
"AllowedValues": [
|
| 19 |
+
"prod",
|
| 20 |
+
"staging",
|
| 21 |
+
"dev",
|
| 22 |
+
"qa"
|
| 23 |
+
],
|
| 24 |
+
"Default": "dev"
|
| 25 |
+
},
|
| 26 |
+
"VpcId": {
|
| 27 |
+
"Description": "Please specify the VPC ID.",
|
| 28 |
+
"Type": "AWS::EC2::VPC::Id",
|
| 29 |
+
"ConstraintDescription": "Must be a valid VPC ID"
|
| 30 |
+
},
|
| 31 |
+
"PublicSubnetId1": {
|
| 32 |
+
"Description": "Please specify first public subnet ID.",
|
| 33 |
+
"Type": "AWS::EC2::Subnet::Id",
|
| 34 |
+
"ConstraintDescription": "Must be a valid subnet ID in the selected VPC"
|
| 35 |
+
},
|
| 36 |
+
"PublicSubnetId2": {
|
| 37 |
+
"Description": "Please specify second public subnet ID.",
|
| 38 |
+
"Type": "AWS::EC2::Subnet::Id",
|
| 39 |
+
"ConstraintDescription": "Must be a valid subnet ID in the selected VPC"
|
| 40 |
+
},
|
| 41 |
+
"AppName": {
|
| 42 |
+
"Description": "Application environment name.",
|
| 43 |
+
"Type": "String",
|
| 44 |
+
"Default": "example"
|
| 45 |
+
},
|
| 46 |
+
"AlternateDomainNames": {
|
| 47 |
+
"Description": "CNAMEs (alternate domain names), if any, for the distribution. Example. mydomain.com",
|
| 48 |
+
"Type": "String",
|
| 49 |
+
"Default": "name.domain.com"
|
| 50 |
+
},
|
| 51 |
+
"ACMCertificateIdentifier": {
|
| 52 |
+
"Description": "The AWS Certificate Manager (ACM) certificate identifier.",
|
| 53 |
+
"Type": "String",
|
| 54 |
+
"Default": "1234567890abcdefgh"
|
| 55 |
+
},
|
| 56 |
+
"LambdaEventType": {
|
| 57 |
+
"Description": "Please specify the event type that triggers a Lambda function invocation.",
|
| 58 |
+
"Type": "String",
|
| 59 |
+
"AllowedValues": [
|
| 60 |
+
"viewer-request",
|
| 61 |
+
"origin-request",
|
| 62 |
+
"origin-response",
|
| 63 |
+
"viewer-response"
|
| 64 |
+
],
|
| 65 |
+
"Default": "viewer-response"
|
| 66 |
+
},
|
| 67 |
+
"IPV6Enabled": {
|
| 68 |
+
"Description": "Should CloudFront to respond to IPv6 DNS requests with an IPv6 address for your distribution.",
|
| 69 |
+
"Type": "String",
|
| 70 |
+
"AllowedValues": [
|
| 71 |
+
"true",
|
| 72 |
+
"false"
|
| 73 |
+
],
|
| 74 |
+
"Default": "true"
|
| 75 |
+
},
|
| 76 |
+
"EC2ImageId": {
|
| 77 |
+
"Description": "EC2 AMI Id",
|
| 78 |
+
"Type": "AWS::EC2::Image::Id",
|
| 79 |
+
"Default": "ami-0d85a662720db9789"
|
| 80 |
+
},
|
| 81 |
+
"EC2InstanceType": {
|
| 82 |
+
"Description": "Amazon EC2 instance type.",
|
| 83 |
+
"Type": "String",
|
| 84 |
+
"AllowedValues": [
|
| 85 |
+
"t2.small",
|
| 86 |
+
"t2.medium",
|
| 87 |
+
"t2.large",
|
| 88 |
+
"t2.xlarge",
|
| 89 |
+
"t2.2xlarge",
|
| 90 |
+
"m4.large",
|
| 91 |
+
"m4.xlarge",
|
| 92 |
+
"m4.2xlarge",
|
| 93 |
+
"m4.4xlarge",
|
| 94 |
+
"m4.10xlarge",
|
| 95 |
+
"m4.16xlarge",
|
| 96 |
+
"m5.large",
|
| 97 |
+
"m5.xlarge",
|
| 98 |
+
"m5.2xlarge",
|
| 99 |
+
"m5.4xlarge",
|
| 100 |
+
"m5.12xlarge",
|
| 101 |
+
"m5.24xlarge",
|
| 102 |
+
"m5d.large",
|
| 103 |
+
"m5d.xlarge",
|
| 104 |
+
"m5d.2xlarge",
|
| 105 |
+
"m5d.4xlarge",
|
| 106 |
+
"m5d.12xlarge",
|
| 107 |
+
"m5d.24xlarge"
|
| 108 |
+
],
|
| 109 |
+
"Default": "t2.small"
|
| 110 |
+
},
|
| 111 |
+
"KeyPairName": {
|
| 112 |
+
"Description": "EC2 KeyPair.",
|
| 113 |
+
"Type": "AWS::EC2::KeyPair::KeyName",
|
| 114 |
+
"ConstraintDescription": "Must be the name of an existing EC2 KeyPair"
|
| 115 |
+
},
|
| 116 |
+
"BootVolSize": {
|
| 117 |
+
"Description": "EC2 Instance Boot volume size.",
|
| 118 |
+
"Type": "String",
|
| 119 |
+
"Default": "100"
|
| 120 |
+
},
|
| 121 |
+
"BootVolType": {
|
| 122 |
+
"Description": "EC2 Instance Boot volume type.",
|
| 123 |
+
"Type": "String",
|
| 124 |
+
"AllowedValues": [
|
| 125 |
+
"gp2",
|
| 126 |
+
"io1",
|
| 127 |
+
"sc1",
|
| 128 |
+
"st1"
|
| 129 |
+
],
|
| 130 |
+
"Default": "gp2"
|
| 131 |
+
},
|
| 132 |
+
"ALBType": {
|
| 133 |
+
"Description": "AWS Load Balancer Type.",
|
| 134 |
+
"Type": "String",
|
| 135 |
+
"AllowedValues": [
|
| 136 |
+
"application",
|
| 137 |
+
"network"
|
| 138 |
+
],
|
| 139 |
+
"Default": "application"
|
| 140 |
+
},
|
| 141 |
+
"OriginALBTGPort": {
|
| 142 |
+
"Description": "Port number the application is running on, for Origin ALB Target Group and Health Check port.",
|
| 143 |
+
"Type": "String",
|
| 144 |
+
"Default": "8080"
|
| 145 |
+
},
|
| 146 |
+
"OriginProtocolPolicy": {
|
| 147 |
+
"Description": "CloudFront Origin Protocol Policy to apply to your origin.",
|
| 148 |
+
"Type": "String",
|
| 149 |
+
"AllowedValues": [
|
| 150 |
+
"http-only",
|
| 151 |
+
"match-viewer",
|
| 152 |
+
"https-only"
|
| 153 |
+
],
|
| 154 |
+
"Default": "http-only"
|
| 155 |
+
},
|
| 156 |
+
"Compress": {
|
| 157 |
+
"Description": "CloudFront should support gzip compression requests: Accept-Encoding: gzip.",
|
| 158 |
+
"Type": "String",
|
| 159 |
+
"AllowedValues": [
|
| 160 |
+
"true",
|
| 161 |
+
"false"
|
| 162 |
+
],
|
| 163 |
+
"Default": "false"
|
| 164 |
+
},
|
| 165 |
+
"DefaultTTL": {
|
| 166 |
+
"Description": "The default time in seconds that objects stay in CloudFront caches before CloudFront forwards another request to your custom origin. By default, AWS CloudFormation specifies 86400 seconds (one day).",
|
| 167 |
+
"Type": "String",
|
| 168 |
+
"Default": "0"
|
| 169 |
+
},
|
| 170 |
+
"MaxTTL": {
|
| 171 |
+
"Description": "The maximum time in seconds that objects stay in CloudFront caches before CloudFront forwards another request to your custom origin. By default, AWS CloudFormation specifies 31536000 seconds (one year).",
|
| 172 |
+
"Type": "String",
|
| 173 |
+
"Default": "0"
|
| 174 |
+
},
|
| 175 |
+
"MinTTL": {
|
| 176 |
+
"Description": "The minimum amount of time that you want objects to stay in the cache before CloudFront queries your origin to see whether the object has been updated.",
|
| 177 |
+
"Type": "String",
|
| 178 |
+
"Default": "0"
|
| 179 |
+
},
|
| 180 |
+
"QueryString": {
|
| 181 |
+
"Description": "CIndicates whether you want CloudFront to forward query strings to the origin that is associated with this cache behavior.",
|
| 182 |
+
"Type": "String",
|
| 183 |
+
"AllowedValues": [
|
| 184 |
+
"true",
|
| 185 |
+
"false"
|
| 186 |
+
],
|
| 187 |
+
"Default": "true"
|
| 188 |
+
},
|
| 189 |
+
"ForwardCookies": {
|
| 190 |
+
"Description": "Forwards specified cookies to the origin of the cache behavior.",
|
| 191 |
+
"Type": "String",
|
| 192 |
+
"AllowedValues": [
|
| 193 |
+
"all",
|
| 194 |
+
"whitelist",
|
| 195 |
+
"none"
|
| 196 |
+
],
|
| 197 |
+
"Default": "all"
|
| 198 |
+
},
|
| 199 |
+
"ViewerProtocolPolicy": {
|
| 200 |
+
"Description": "The protocol that users can use to access the files in the origin that you specified in the TargetOriginId property when the default cache behavior is applied to a request.",
|
| 201 |
+
"Type": "String",
|
| 202 |
+
"AllowedValues": [
|
| 203 |
+
"redirect-to-https",
|
| 204 |
+
"allow-all",
|
| 205 |
+
"https-only"
|
| 206 |
+
],
|
| 207 |
+
"Default": "redirect-to-https"
|
| 208 |
+
},
|
| 209 |
+
"PriceClass": {
|
| 210 |
+
"Description": "The price class that corresponds with the maximum price that you want to pay for CloudFront service. If you specify PriceClass_All, CloudFront responds to requests for your objects from all CloudFront edge locations.",
|
| 211 |
+
"Type": "String",
|
| 212 |
+
"AllowedValues": [
|
| 213 |
+
"PriceClass_All",
|
| 214 |
+
"PriceClass_100",
|
| 215 |
+
"PriceClass_200"
|
| 216 |
+
],
|
| 217 |
+
"Default": "PriceClass_All"
|
| 218 |
+
},
|
| 219 |
+
"SslSupportMethod": {
|
| 220 |
+
"Description": "Specifies how CloudFront serves HTTPS requests.",
|
| 221 |
+
"Type": "String",
|
| 222 |
+
"AllowedValues": [
|
| 223 |
+
"sni-only",
|
| 224 |
+
"vip"
|
| 225 |
+
],
|
| 226 |
+
"Default": "sni-only"
|
| 227 |
+
},
|
| 228 |
+
"MinimumProtocolVersion": {
|
| 229 |
+
"Description": "The minimum version of the SSL protocol that you want CloudFront to use for HTTPS connections.",
|
| 230 |
+
"Type": "String",
|
| 231 |
+
"AllowedValues": [
|
| 232 |
+
"TLSv1",
|
| 233 |
+
"TLSv1.2_2018",
|
| 234 |
+
"TLSv1.1_2016",
|
| 235 |
+
"TLSv1_2016",
|
| 236 |
+
"SSLv3"
|
| 237 |
+
],
|
| 238 |
+
"Default": "TLSv1"
|
| 239 |
+
},
|
| 240 |
+
"OriginKeepaliveTimeout": {
|
| 241 |
+
"Description": "You can create a custom keep-alive timeout. All timeout units are in seconds. The default keep-alive timeout is 5 seconds, but you can configure custom timeout lengths. The minimum timeout length is 1 second; the maximum is 60 seconds.",
|
| 242 |
+
"Type": "String",
|
| 243 |
+
"Default": "60"
|
| 244 |
+
},
|
| 245 |
+
"OriginReadTimeout": {
|
| 246 |
+
"Description": "You can create a custom origin read timeout. All timeout units are in seconds. The default origin read timeout is 30 seconds, but you can configure custom timeout lengths. The minimum timeout length is 4 seconds; the maximum is 60 seconds.",
|
| 247 |
+
"Type": "String",
|
| 248 |
+
"Default": "30"
|
| 249 |
+
},
|
| 250 |
+
"ALBScheme": {
|
| 251 |
+
"Description": "Origin ALB scheme.",
|
| 252 |
+
"Type": "String",
|
| 253 |
+
"AllowedValues": [
|
| 254 |
+
"internet-facing",
|
| 255 |
+
"internal"
|
| 256 |
+
],
|
| 257 |
+
"Default": "internet-facing"
|
| 258 |
+
},
|
| 259 |
+
"ALBTargetGroupHealthCheckIntervalSeconds": {
|
| 260 |
+
"Description": "Origin ALB Target Group Health Check Interval in Seconds.",
|
| 261 |
+
"Type": "String",
|
| 262 |
+
"Default": "30"
|
| 263 |
+
},
|
| 264 |
+
"ALBTargetGroupHealthCheckTimeoutSeconds": {
|
| 265 |
+
"Description": "Origin ALB Target Group Health Check Timeout in Seconds.",
|
| 266 |
+
"Type": "String",
|
| 267 |
+
"Default": "5"
|
| 268 |
+
},
|
| 269 |
+
"ALBTargetGroupHealthyThresholdCount": {
|
| 270 |
+
"Description": "Origin ALB Target Group Healthy Threshold Count.",
|
| 271 |
+
"Type": "String",
|
| 272 |
+
"Default": "5"
|
| 273 |
+
},
|
| 274 |
+
"ALBTargetGroupUnhealthyThresholdCount": {
|
| 275 |
+
"Description": "Origin ALB Target Group Unhealthy Threshold Count.",
|
| 276 |
+
"Type": "String",
|
| 277 |
+
"Default": "2"
|
| 278 |
+
},
|
| 279 |
+
"ALBAttributeIdleTimeOut": {
|
| 280 |
+
"Description": "Origin ALB Target Group Unhealthy Threshold Count.",
|
| 281 |
+
"Type": "String",
|
| 282 |
+
"Default": "60"
|
| 283 |
+
},
|
| 284 |
+
"ALBAttributeDeletionProtection": {
|
| 285 |
+
"Description": "Origin ALB Target Group Unhealthy Threshold Count.",
|
| 286 |
+
"Type": "String",
|
| 287 |
+
"AllowedValues": [
|
| 288 |
+
"true",
|
| 289 |
+
"false"
|
| 290 |
+
],
|
| 291 |
+
"Default": "false"
|
| 292 |
+
},
|
| 293 |
+
"ALBAttributeRoutingHttp2": {
|
| 294 |
+
"Description": "Origin ALB Target Group Unhealthy Threshold Count.",
|
| 295 |
+
"Type": "String",
|
| 296 |
+
"AllowedValues": [
|
| 297 |
+
"true",
|
| 298 |
+
"false"
|
| 299 |
+
],
|
| 300 |
+
"Default": "true"
|
| 301 |
+
},
|
| 302 |
+
"ALBTargetGroupAttributeDeregistration": {
|
| 303 |
+
"Description": "Origin ALB Target Group Deregistration Timeout.",
|
| 304 |
+
"Type": "String",
|
| 305 |
+
"Default": "300"
|
| 306 |
+
},
|
| 307 |
+
"HealthCheckProtocol": {
|
| 308 |
+
"Description": "Origin ALB Target Group Health Check Protocol.",
|
| 309 |
+
"Type": "String",
|
| 310 |
+
"AllowedValues": [
|
| 311 |
+
"HTTPS",
|
| 312 |
+
"HTTP"
|
| 313 |
+
],
|
| 314 |
+
"Default": "HTTP"
|
| 315 |
+
},
|
| 316 |
+
"HealthCheckPath": {
|
| 317 |
+
"Description": "Origin ALB Target Group Health Check Path.",
|
| 318 |
+
"Type": "String",
|
| 319 |
+
"Default": "/health.html"
|
| 320 |
+
},
|
| 321 |
+
"LoggingBucketVersioning": {
|
| 322 |
+
"Description": "The versioning state of an Amazon S3 bucket. If you enable versioning, you must suspend versioning to disable it.",
|
| 323 |
+
"Type": "String",
|
| 324 |
+
"AllowedValues": [
|
| 325 |
+
"Enabled",
|
| 326 |
+
"Suspended"
|
| 327 |
+
],
|
| 328 |
+
"Default": "Suspended"
|
| 329 |
+
}
|
| 330 |
+
},
|
| 331 |
+
"Resources": {
|
| 332 |
+
"AdministratorAccessIAMRole": {
|
| 333 |
+
"Type": "AWS::IAM::Role",
|
| 334 |
+
"Properties": {
|
| 335 |
+
"RoleName": {
|
| 336 |
+
"Fn::Sub": "AdministratorAccess-${AppName}"
|
| 337 |
+
},
|
| 338 |
+
"ManagedPolicyArns": [
|
| 339 |
+
{
|
| 340 |
+
"Fn::Sub": "arn:${AWS::Partition}:iam::aws:policy/AdministratorAccess"
|
| 341 |
+
}
|
| 342 |
+
],
|
| 343 |
+
"AssumeRolePolicyDocument": {
|
| 344 |
+
"Version": "2012-10-17",
|
| 345 |
+
"Statement": [
|
| 346 |
+
{
|
| 347 |
+
"Effect": "Allow",
|
| 348 |
+
"Principal": {
|
| 349 |
+
"Service": [
|
| 350 |
+
"ec2.amazonaws.com"
|
| 351 |
+
]
|
| 352 |
+
},
|
| 353 |
+
"Action": [
|
| 354 |
+
"sts:AssumeRole"
|
| 355 |
+
]
|
| 356 |
+
}
|
| 357 |
+
]
|
| 358 |
+
},
|
| 359 |
+
"Path": "/"
|
| 360 |
+
}
|
| 361 |
+
},
|
| 362 |
+
"LambdaEdgeIAMRole": {
|
| 363 |
+
"Type": "AWS::IAM::Role",
|
| 364 |
+
"Properties": {
|
| 365 |
+
"RoleName": {
|
| 366 |
+
"Fn::Sub": "${AppName}-iam-lambda-edge-role-${Environment}"
|
| 367 |
+
},
|
| 368 |
+
"AssumeRolePolicyDocument": {
|
| 369 |
+
"Version": "2012-10-17",
|
| 370 |
+
"Statement": [
|
| 371 |
+
{
|
| 372 |
+
"Sid": "AllowLambdaServiceToAssumeRole",
|
| 373 |
+
"Effect": "Allow",
|
| 374 |
+
"Principal": {
|
| 375 |
+
"Service": [
|
| 376 |
+
"edgelambda.amazonaws.com",
|
| 377 |
+
"lambda.amazonaws.com"
|
| 378 |
+
]
|
| 379 |
+
},
|
| 380 |
+
"Action": [
|
| 381 |
+
"sts:AssumeRole"
|
| 382 |
+
]
|
| 383 |
+
}
|
| 384 |
+
]
|
| 385 |
+
},
|
| 386 |
+
"ManagedPolicyArns": [
|
| 387 |
+
"arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole",
|
| 388 |
+
"arn:aws:iam::aws:policy/AWSXrayWriteOnlyAccess"
|
| 389 |
+
],
|
| 390 |
+
"Path": "/",
|
| 391 |
+
"Policies": [
|
| 392 |
+
{
|
| 393 |
+
"PolicyName": "PublishNewLambdaEdgeVersion",
|
| 394 |
+
"PolicyDocument": {
|
| 395 |
+
"Version": "2012-10-17",
|
| 396 |
+
"Statement": [
|
| 397 |
+
{
|
| 398 |
+
"Effect": "Allow",
|
| 399 |
+
"Action": [
|
| 400 |
+
"lambda:PublishVersion"
|
| 401 |
+
],
|
| 402 |
+
"Resource": "*"
|
| 403 |
+
}
|
| 404 |
+
]
|
| 405 |
+
}
|
| 406 |
+
}
|
| 407 |
+
]
|
| 408 |
+
}
|
| 409 |
+
},
|
| 410 |
+
"LoggingBucketKMSKey": {
|
| 411 |
+
"Type": "AWS::KMS::Key",
|
| 412 |
+
"DependsOn": "AdministratorAccessIAMRole",
|
| 413 |
+
"Properties": {
|
| 414 |
+
"Description": "Logging S3 Bucket KMS Key",
|
| 415 |
+
"Enabled": true,
|
| 416 |
+
"EnableKeyRotation": true,
|
| 417 |
+
"KeyPolicy": {
|
| 418 |
+
"Version": "2012-10-17",
|
| 419 |
+
"Statement": [
|
| 420 |
+
{
|
| 421 |
+
"Sid": "Enable IAM policies to allow access to the Key",
|
| 422 |
+
"Effect": "Allow",
|
| 423 |
+
"Principal": {
|
| 424 |
+
"AWS": {
|
| 425 |
+
"Fn::Sub": "arn:${AWS::Partition}:iam::${AWS::AccountId}:root"
|
| 426 |
+
}
|
| 427 |
+
},
|
| 428 |
+
"Action": [
|
| 429 |
+
"kms:*"
|
| 430 |
+
],
|
| 431 |
+
"Resource": "*"
|
| 432 |
+
},
|
| 433 |
+
{
|
| 434 |
+
"Sid": "Allow administration of the key",
|
| 435 |
+
"Effect": "Allow",
|
| 436 |
+
"Principal": {
|
| 437 |
+
"AWS": [
|
| 438 |
+
{
|
| 439 |
+
"Fn::Sub": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/AdministratorAccess-${AppName}"
|
| 440 |
+
}
|
| 441 |
+
]
|
| 442 |
+
},
|
| 443 |
+
"Action": [
|
| 444 |
+
"kms:Put*",
|
| 445 |
+
"kms:ScheduleKeyDeletion",
|
| 446 |
+
"kms:CancelKeyDeletion",
|
| 447 |
+
"kms:Describe*",
|
| 448 |
+
"kms:Revoke*",
|
| 449 |
+
"kms:Disable*",
|
| 450 |
+
"kms:Enable*",
|
| 451 |
+
"kms:Delete*",
|
| 452 |
+
"kms:List*",
|
| 453 |
+
"kms:Update*",
|
| 454 |
+
"kms:Create*"
|
| 455 |
+
],
|
| 456 |
+
"Resource": "*"
|
| 457 |
+
}
|
| 458 |
+
]
|
| 459 |
+
}
|
| 460 |
+
}
|
| 461 |
+
},
|
| 462 |
+
"LoggingBucketKMSKeyAlias": {
|
| 463 |
+
"Type": "AWS::KMS::Alias",
|
| 464 |
+
"Properties": {
|
| 465 |
+
"AliasName": {
|
| 466 |
+
"Fn::Sub": "alias/${AppName}/${Environment}/s3-logging-kms"
|
| 467 |
+
},
|
| 468 |
+
"TargetKeyId": {
|
| 469 |
+
"Fn::Sub": "${LoggingBucketKMSKey}"
|
| 470 |
+
}
|
| 471 |
+
}
|
| 472 |
+
},
|
| 473 |
+
"LoggingBucket": {
|
| 474 |
+
"DeletionPolicy": "Retain",
|
| 475 |
+
"UpdateReplacePolicy": "Retain",
|
| 476 |
+
"Type": "AWS::S3::Bucket",
|
| 477 |
+
"DependsOn": "LoggingBucketKMSKey",
|
| 478 |
+
"Metadata": {
|
| 479 |
+
"guard": {
|
| 480 |
+
"SuppressedRules": [
|
| 481 |
+
"S3_BUCKET_DEFAULT_LOCK_ENABLED",
|
| 482 |
+
"S3_BUCKET_VERSIONING_ENABLED",
|
| 483 |
+
"S3_BUCKET_REPLICATION_ENABLED",
|
| 484 |
+
"S3_BUCKET_LOGGING_ENABLED"
|
| 485 |
+
]
|
| 486 |
+
}
|
| 487 |
+
},
|
| 488 |
+
"Properties": {
|
| 489 |
+
"BucketName": {
|
| 490 |
+
"Fn::Sub": "${AppName}-logging-${Environment}-${AWS::AccountId}-${AWS::Region}"
|
| 491 |
+
},
|
| 492 |
+
"OwnershipControls": {
|
| 493 |
+
"Rules": [
|
| 494 |
+
{
|
| 495 |
+
"ObjectOwnership": "ObjectWriter"
|
| 496 |
+
}
|
| 497 |
+
]
|
| 498 |
+
},
|
| 499 |
+
"PublicAccessBlockConfiguration": {
|
| 500 |
+
"BlockPublicAcls": true,
|
| 501 |
+
"BlockPublicPolicy": true,
|
| 502 |
+
"IgnorePublicAcls": true,
|
| 503 |
+
"RestrictPublicBuckets": true
|
| 504 |
+
},
|
| 505 |
+
"AccessControl": "LogDeliveryWrite",
|
| 506 |
+
"BucketEncryption": {
|
| 507 |
+
"ServerSideEncryptionConfiguration": [
|
| 508 |
+
{
|
| 509 |
+
"ServerSideEncryptionByDefault": {
|
| 510 |
+
"KMSMasterKeyID": {
|
| 511 |
+
"Fn::GetAtt": [
|
| 512 |
+
"LoggingBucketKMSKey",
|
| 513 |
+
"Arn"
|
| 514 |
+
]
|
| 515 |
+
},
|
| 516 |
+
"SSEAlgorithm": "aws:kms"
|
| 517 |
+
}
|
| 518 |
+
}
|
| 519 |
+
]
|
| 520 |
+
},
|
| 521 |
+
"VersioningConfiguration": {
|
| 522 |
+
"Status": {
|
| 523 |
+
"Ref": "LoggingBucketVersioning"
|
| 524 |
+
}
|
| 525 |
+
}
|
| 526 |
+
}
|
| 527 |
+
},
|
| 528 |
+
"LoggingBucketPolicy": {
|
| 529 |
+
"Type": "AWS::S3::BucketPolicy",
|
| 530 |
+
"Properties": {
|
| 531 |
+
"Bucket": {
|
| 532 |
+
"Ref": "LoggingBucket"
|
| 533 |
+
},
|
| 534 |
+
"PolicyDocument": {
|
| 535 |
+
"Version": "2012-10-17",
|
| 536 |
+
"Statement": [
|
| 537 |
+
{
|
| 538 |
+
"Sid": "LoggingBucketPermissions",
|
| 539 |
+
"Effect": "Allow",
|
| 540 |
+
"Principal": {
|
| 541 |
+
"AWS": {
|
| 542 |
+
"Fn::Sub": "arn:${AWS::Partition}:iam::${AWS::AccountId}:root"
|
| 543 |
+
}
|
| 544 |
+
},
|
| 545 |
+
"Action": "s3:PutObject",
|
| 546 |
+
"Resource": [
|
| 547 |
+
{
|
| 548 |
+
"Fn::Sub": "arn:${AWS::Partition}:s3:::${LoggingBucket}/AWSLogs/${AWS::AccountId}/*"
|
| 549 |
+
}
|
| 550 |
+
]
|
| 551 |
+
},
|
| 552 |
+
{
|
| 553 |
+
"Action": "s3:*",
|
| 554 |
+
"Condition": {
|
| 555 |
+
"Bool": {
|
| 556 |
+
"aws:SecureTransport": false
|
| 557 |
+
}
|
| 558 |
+
},
|
| 559 |
+
"Effect": "Deny",
|
| 560 |
+
"Principal": {
|
| 561 |
+
"AWS": "*"
|
| 562 |
+
},
|
| 563 |
+
"Resource": [
|
| 564 |
+
{
|
| 565 |
+
"Fn::Sub": "arn:${AWS::Partition}:s3:::${LoggingBucket}/AWSLogs/${AWS::AccountId}/*"
|
| 566 |
+
}
|
| 567 |
+
]
|
| 568 |
+
}
|
| 569 |
+
]
|
| 570 |
+
}
|
| 571 |
+
}
|
| 572 |
+
},
|
| 573 |
+
"EC2Instance": {
|
| 574 |
+
"Type": "AWS::EC2::Instance",
|
| 575 |
+
"Properties": {
|
| 576 |
+
"ImageId": {
|
| 577 |
+
"Ref": "EC2ImageId"
|
| 578 |
+
},
|
| 579 |
+
"InstanceType": {
|
| 580 |
+
"Ref": "EC2InstanceType"
|
| 581 |
+
},
|
| 582 |
+
"SubnetId": {
|
| 583 |
+
"Ref": "PublicSubnetId1"
|
| 584 |
+
},
|
| 585 |
+
"BlockDeviceMappings": [
|
| 586 |
+
{
|
| 587 |
+
"DeviceName": "/dev/sda1",
|
| 588 |
+
"Ebs": {
|
| 589 |
+
"VolumeSize": {
|
| 590 |
+
"Ref": "BootVolSize"
|
| 591 |
+
},
|
| 592 |
+
"VolumeType": {
|
| 593 |
+
"Ref": "BootVolType"
|
| 594 |
+
}
|
| 595 |
+
}
|
| 596 |
+
}
|
| 597 |
+
],
|
| 598 |
+
"SecurityGroupIds": [
|
| 599 |
+
{
|
| 600 |
+
"Ref": "EC2InstanceSG"
|
| 601 |
+
},
|
| 602 |
+
{
|
| 603 |
+
"Ref": "ALBExternalAccessSG"
|
| 604 |
+
}
|
| 605 |
+
],
|
| 606 |
+
"KeyName": {
|
| 607 |
+
"Ref": "KeyPairName"
|
| 608 |
+
},
|
| 609 |
+
"Tags": [
|
| 610 |
+
{
|
| 611 |
+
"Key": "Name",
|
| 612 |
+
"Value": {
|
| 613 |
+
"Fn::Sub": "${AppName}-${Environment}-ec2-instance"
|
| 614 |
+
}
|
| 615 |
+
},
|
| 616 |
+
{
|
| 617 |
+
"Key": "Environment",
|
| 618 |
+
"Value": {
|
| 619 |
+
"Ref": "Environment"
|
| 620 |
+
}
|
| 621 |
+
}
|
| 622 |
+
]
|
| 623 |
+
}
|
| 624 |
+
},
|
| 625 |
+
"EC2InstanceSG": {
|
| 626 |
+
"Type": "AWS::EC2::SecurityGroup",
|
| 627 |
+
"Properties": {
|
| 628 |
+
"GroupDescription": "EC2 Instance Security Group",
|
| 629 |
+
"VpcId": {
|
| 630 |
+
"Ref": "VpcId"
|
| 631 |
+
},
|
| 632 |
+
"Tags": [
|
| 633 |
+
{
|
| 634 |
+
"Key": "Name",
|
| 635 |
+
"Value": {
|
| 636 |
+
"Fn::Sub": "${AppName}-${Environment}-ec2-instance-SG"
|
| 637 |
+
}
|
| 638 |
+
},
|
| 639 |
+
{
|
| 640 |
+
"Key": "Environment",
|
| 641 |
+
"Value": {
|
| 642 |
+
"Ref": "Environment"
|
| 643 |
+
}
|
| 644 |
+
}
|
| 645 |
+
]
|
| 646 |
+
}
|
| 647 |
+
},
|
| 648 |
+
"Tcp8080In": {
|
| 649 |
+
"Type": "AWS::EC2::SecurityGroupIngress",
|
| 650 |
+
"Properties": {
|
| 651 |
+
"GroupId": {
|
| 652 |
+
"Ref": "EC2InstanceSG"
|
| 653 |
+
},
|
| 654 |
+
"ToPort": "8080",
|
| 655 |
+
"IpProtocol": "tcp",
|
| 656 |
+
"FromPort": "8080",
|
| 657 |
+
"SourceSecurityGroupId": {
|
| 658 |
+
"Ref": "ALBExternalAccessSG"
|
| 659 |
+
}
|
| 660 |
+
}
|
| 661 |
+
},
|
| 662 |
+
"OriginALB": {
|
| 663 |
+
"Type": "AWS::ElasticLoadBalancingV2::LoadBalancer",
|
| 664 |
+
"Properties": {
|
| 665 |
+
"Name": {
|
| 666 |
+
"Fn::Sub": "${AppName}-${Environment}-alb"
|
| 667 |
+
},
|
| 668 |
+
"Scheme": {
|
| 669 |
+
"Ref": "ALBScheme"
|
| 670 |
+
},
|
| 671 |
+
"Type": {
|
| 672 |
+
"Ref": "ALBType"
|
| 673 |
+
},
|
| 674 |
+
"LoadBalancerAttributes": [
|
| 675 |
+
{
|
| 676 |
+
"Key": "idle_timeout.timeout_seconds",
|
| 677 |
+
"Value": {
|
| 678 |
+
"Ref": "ALBAttributeIdleTimeOut"
|
| 679 |
+
}
|
| 680 |
+
},
|
| 681 |
+
{
|
| 682 |
+
"Key": "deletion_protection.enabled",
|
| 683 |
+
"Value": {
|
| 684 |
+
"Ref": "ALBAttributeDeletionProtection"
|
| 685 |
+
}
|
| 686 |
+
},
|
| 687 |
+
{
|
| 688 |
+
"Key": "routing.http2.enabled",
|
| 689 |
+
"Value": {
|
| 690 |
+
"Ref": "ALBAttributeRoutingHttp2"
|
| 691 |
+
}
|
| 692 |
+
}
|
| 693 |
+
],
|
| 694 |
+
"Subnets": [
|
| 695 |
+
{
|
| 696 |
+
"Ref": "PublicSubnetId1"
|
| 697 |
+
},
|
| 698 |
+
{
|
| 699 |
+
"Ref": "PublicSubnetId2"
|
| 700 |
+
}
|
| 701 |
+
],
|
| 702 |
+
"SecurityGroups": [
|
| 703 |
+
{
|
| 704 |
+
"Ref": "ALBExternalAccessSG"
|
| 705 |
+
}
|
| 706 |
+
],
|
| 707 |
+
"Tags": [
|
| 708 |
+
{
|
| 709 |
+
"Key": "Name",
|
| 710 |
+
"Value": {
|
| 711 |
+
"Fn::Sub": "${AppName}-${Environment}-alb"
|
| 712 |
+
}
|
| 713 |
+
},
|
| 714 |
+
{
|
| 715 |
+
"Key": "Environment",
|
| 716 |
+
"Value": {
|
| 717 |
+
"Ref": "Environment"
|
| 718 |
+
}
|
| 719 |
+
}
|
| 720 |
+
]
|
| 721 |
+
}
|
| 722 |
+
},
|
| 723 |
+
"OriginALBTG": {
|
| 724 |
+
"Type": "AWS::ElasticLoadBalancingV2::TargetGroup",
|
| 725 |
+
"DependsOn": "OriginALB",
|
| 726 |
+
"Properties": {
|
| 727 |
+
"Name": {
|
| 728 |
+
"Fn::Sub": "${AppName}-${Environment}-alb-tg"
|
| 729 |
+
},
|
| 730 |
+
"HealthCheckProtocol": {
|
| 731 |
+
"Ref": "HealthCheckProtocol"
|
| 732 |
+
},
|
| 733 |
+
"HealthCheckPath": {
|
| 734 |
+
"Ref": "HealthCheckPath"
|
| 735 |
+
},
|
| 736 |
+
"HealthCheckPort": {
|
| 737 |
+
"Fn::Sub": "${OriginALBTGPort}"
|
| 738 |
+
},
|
| 739 |
+
"HealthCheckIntervalSeconds": {
|
| 740 |
+
"Ref": "ALBTargetGroupHealthCheckIntervalSeconds"
|
| 741 |
+
},
|
| 742 |
+
"HealthCheckTimeoutSeconds": {
|
| 743 |
+
"Ref": "ALBTargetGroupHealthCheckTimeoutSeconds"
|
| 744 |
+
},
|
| 745 |
+
"HealthyThresholdCount": {
|
| 746 |
+
"Ref": "ALBTargetGroupHealthyThresholdCount"
|
| 747 |
+
},
|
| 748 |
+
"UnhealthyThresholdCount": {
|
| 749 |
+
"Ref": "ALBTargetGroupUnhealthyThresholdCount"
|
| 750 |
+
},
|
| 751 |
+
"TargetGroupAttributes": [
|
| 752 |
+
{
|
| 753 |
+
"Key": "deregistration_delay.timeout_seconds",
|
| 754 |
+
"Value": {
|
| 755 |
+
"Ref": "ALBTargetGroupAttributeDeregistration"
|
| 756 |
+
}
|
| 757 |
+
}
|
| 758 |
+
],
|
| 759 |
+
"TargetType": "instance",
|
| 760 |
+
"Targets": [
|
| 761 |
+
{
|
| 762 |
+
"Id": {
|
| 763 |
+
"Ref": "EC2Instance"
|
| 764 |
+
},
|
| 765 |
+
"Port": {
|
| 766 |
+
"Ref": "OriginALBTGPort"
|
| 767 |
+
}
|
| 768 |
+
}
|
| 769 |
+
],
|
| 770 |
+
"Port": {
|
| 771 |
+
"Ref": "OriginALBTGPort"
|
| 772 |
+
},
|
| 773 |
+
"Protocol": "HTTP",
|
| 774 |
+
"VpcId": {
|
| 775 |
+
"Ref": "VpcId"
|
| 776 |
+
},
|
| 777 |
+
"Tags": [
|
| 778 |
+
{
|
| 779 |
+
"Key": "Name",
|
| 780 |
+
"Value": {
|
| 781 |
+
"Fn::Sub": "${AppName}-${Environment}-alb-tg"
|
| 782 |
+
}
|
| 783 |
+
},
|
| 784 |
+
{
|
| 785 |
+
"Key": "Environment",
|
| 786 |
+
"Value": {
|
| 787 |
+
"Ref": "Environment"
|
| 788 |
+
}
|
| 789 |
+
}
|
| 790 |
+
]
|
| 791 |
+
}
|
| 792 |
+
},
|
| 793 |
+
"OriginALBHttpsListener": {
|
| 794 |
+
"Type": "AWS::ElasticLoadBalancingV2::Listener",
|
| 795 |
+
"DependsOn": "OriginALBTG",
|
| 796 |
+
"Properties": {
|
| 797 |
+
"DefaultActions": [
|
| 798 |
+
{
|
| 799 |
+
"TargetGroupArn": {
|
| 800 |
+
"Ref": "OriginALBTG"
|
| 801 |
+
},
|
| 802 |
+
"Type": "forward"
|
| 803 |
+
}
|
| 804 |
+
],
|
| 805 |
+
"LoadBalancerArn": {
|
| 806 |
+
"Ref": "OriginALB"
|
| 807 |
+
},
|
| 808 |
+
"Port": 443,
|
| 809 |
+
"Protocol": "HTTPS",
|
| 810 |
+
"Certificates": [
|
| 811 |
+
{
|
| 812 |
+
"CertificateArn": {
|
| 813 |
+
"Fn::Sub": "arn:${AWS::Partition}:acm:${AWS::Region}:${AWS::AccountId}:certificate/${ACMCertificateIdentifier}"
|
| 814 |
+
}
|
| 815 |
+
}
|
| 816 |
+
],
|
| 817 |
+
"SslPolicy": "ELBSecurityPolicy-FS-2018-06"
|
| 818 |
+
}
|
| 819 |
+
},
|
| 820 |
+
"OriginALBHttpsListenerRule": {
|
| 821 |
+
"Type": "AWS::ElasticLoadBalancingV2::ListenerRule",
|
| 822 |
+
"DependsOn": "OriginALBHttpsListener",
|
| 823 |
+
"Properties": {
|
| 824 |
+
"Actions": [
|
| 825 |
+
{
|
| 826 |
+
"Type": "forward",
|
| 827 |
+
"TargetGroupArn": {
|
| 828 |
+
"Ref": "OriginALBTG"
|
| 829 |
+
}
|
| 830 |
+
}
|
| 831 |
+
],
|
| 832 |
+
"Conditions": [
|
| 833 |
+
{
|
| 834 |
+
"Field": "path-pattern",
|
| 835 |
+
"Values": [
|
| 836 |
+
"/*"
|
| 837 |
+
]
|
| 838 |
+
}
|
| 839 |
+
],
|
| 840 |
+
"ListenerArn": {
|
| 841 |
+
"Ref": "OriginALBHttpsListener"
|
| 842 |
+
},
|
| 843 |
+
"Priority": 1
|
| 844 |
+
}
|
| 845 |
+
},
|
| 846 |
+
"ALBExternalAccessSG": {
|
| 847 |
+
"Type": "AWS::EC2::SecurityGroup",
|
| 848 |
+
"Properties": {
|
| 849 |
+
"GroupDescription": "Allow external access to ALB",
|
| 850 |
+
"VpcId": {
|
| 851 |
+
"Ref": "VpcId"
|
| 852 |
+
},
|
| 853 |
+
"Tags": [
|
| 854 |
+
{
|
| 855 |
+
"Key": "Name",
|
| 856 |
+
"Value": {
|
| 857 |
+
"Fn::Sub": "${AppName}-${Environment}-alb-external-access-ingrees-SG"
|
| 858 |
+
}
|
| 859 |
+
},
|
| 860 |
+
{
|
| 861 |
+
"Key": "Environment",
|
| 862 |
+
"Value": {
|
| 863 |
+
"Ref": "Environment"
|
| 864 |
+
}
|
| 865 |
+
}
|
| 866 |
+
]
|
| 867 |
+
}
|
| 868 |
+
},
|
| 869 |
+
"HTTPSTcpIn": {
|
| 870 |
+
"Type": "AWS::EC2::SecurityGroupIngress",
|
| 871 |
+
"Properties": {
|
| 872 |
+
"GroupId": {
|
| 873 |
+
"Ref": "ALBExternalAccessSG"
|
| 874 |
+
},
|
| 875 |
+
"ToPort": 443,
|
| 876 |
+
"IpProtocol": "tcp",
|
| 877 |
+
"FromPort": 443,
|
| 878 |
+
"CidrIp": "0.0.0.0/0"
|
| 879 |
+
}
|
| 880 |
+
},
|
| 881 |
+
"HTTPTcpIn": {
|
| 882 |
+
"Type": "AWS::EC2::SecurityGroupIngress",
|
| 883 |
+
"Properties": {
|
| 884 |
+
"GroupId": {
|
| 885 |
+
"Ref": "ALBExternalAccessSG"
|
| 886 |
+
},
|
| 887 |
+
"ToPort": 80,
|
| 888 |
+
"IpProtocol": "tcp",
|
| 889 |
+
"FromPort": 80,
|
| 890 |
+
"CidrIp": "0.0.0.0/0"
|
| 891 |
+
}
|
| 892 |
+
},
|
| 893 |
+
"Tcp8080Out": {
|
| 894 |
+
"Type": "AWS::EC2::SecurityGroupEgress",
|
| 895 |
+
"Properties": {
|
| 896 |
+
"GroupId": {
|
| 897 |
+
"Ref": "ALBExternalAccessSG"
|
| 898 |
+
},
|
| 899 |
+
"ToPort": 8080,
|
| 900 |
+
"IpProtocol": "tcp",
|
| 901 |
+
"FromPort": 8080,
|
| 902 |
+
"DestinationSecurityGroupId": {
|
| 903 |
+
"Ref": "EC2InstanceSG"
|
| 904 |
+
}
|
| 905 |
+
}
|
| 906 |
+
},
|
| 907 |
+
"CloudFrontDistribution": {
|
| 908 |
+
"Type": "AWS::CloudFront::Distribution",
|
| 909 |
+
"DependsOn": [
|
| 910 |
+
"LoggingBucket",
|
| 911 |
+
"LambdaEdgeFunction"
|
| 912 |
+
],
|
| 913 |
+
"Properties": {
|
| 914 |
+
"DistributionConfig": {
|
| 915 |
+
"Comment": "Cloudfront Distribution pointing ALB Origin",
|
| 916 |
+
"Origins": [
|
| 917 |
+
{
|
| 918 |
+
"DomainName": {
|
| 919 |
+
"Fn::GetAtt": [
|
| 920 |
+
"OriginALB",
|
| 921 |
+
"DNSName"
|
| 922 |
+
]
|
| 923 |
+
},
|
| 924 |
+
"Id": {
|
| 925 |
+
"Ref": "OriginALB"
|
| 926 |
+
},
|
| 927 |
+
"CustomOriginConfig": {
|
| 928 |
+
"HTTPPort": 80,
|
| 929 |
+
"HTTPSPort": 443,
|
| 930 |
+
"OriginProtocolPolicy": {
|
| 931 |
+
"Ref": "OriginProtocolPolicy"
|
| 932 |
+
},
|
| 933 |
+
"OriginKeepaliveTimeout": {
|
| 934 |
+
"Ref": "OriginKeepaliveTimeout"
|
| 935 |
+
},
|
| 936 |
+
"OriginReadTimeout": {
|
| 937 |
+
"Ref": "OriginReadTimeout"
|
| 938 |
+
},
|
| 939 |
+
"OriginSSLProtocols": [
|
| 940 |
+
"TLSv1",
|
| 941 |
+
"TLSv1.1",
|
| 942 |
+
"TLSv1.2",
|
| 943 |
+
"SSLv3"
|
| 944 |
+
]
|
| 945 |
+
}
|
| 946 |
+
}
|
| 947 |
+
],
|
| 948 |
+
"Enabled": true,
|
| 949 |
+
"HttpVersion": "http2",
|
| 950 |
+
"Aliases": [
|
| 951 |
+
{
|
| 952 |
+
"Ref": "AlternateDomainNames"
|
| 953 |
+
}
|
| 954 |
+
],
|
| 955 |
+
"DefaultCacheBehavior": {
|
| 956 |
+
"AllowedMethods": [
|
| 957 |
+
"GET",
|
| 958 |
+
"HEAD",
|
| 959 |
+
"DELETE",
|
| 960 |
+
"OPTIONS",
|
| 961 |
+
"PATCH",
|
| 962 |
+
"POST",
|
| 963 |
+
"PUT"
|
| 964 |
+
],
|
| 965 |
+
"Compress": {
|
| 966 |
+
"Ref": "Compress"
|
| 967 |
+
},
|
| 968 |
+
"DefaultTTL": {
|
| 969 |
+
"Ref": "DefaultTTL"
|
| 970 |
+
},
|
| 971 |
+
"MaxTTL": {
|
| 972 |
+
"Ref": "MaxTTL"
|
| 973 |
+
},
|
| 974 |
+
"MinTTL": {
|
| 975 |
+
"Ref": "MinTTL"
|
| 976 |
+
},
|
| 977 |
+
"SmoothStreaming": "false",
|
| 978 |
+
"TargetOriginId": {
|
| 979 |
+
"Ref": "OriginALB"
|
| 980 |
+
},
|
| 981 |
+
"ForwardedValues": {
|
| 982 |
+
"QueryString": {
|
| 983 |
+
"Ref": "QueryString"
|
| 984 |
+
},
|
| 985 |
+
"Cookies": {
|
| 986 |
+
"Forward": {
|
| 987 |
+
"Ref": "ForwardCookies"
|
| 988 |
+
}
|
| 989 |
+
}
|
| 990 |
+
},
|
| 991 |
+
"ViewerProtocolPolicy": {
|
| 992 |
+
"Ref": "ViewerProtocolPolicy"
|
| 993 |
+
},
|
| 994 |
+
"LambdaFunctionAssociations": [
|
| 995 |
+
{
|
| 996 |
+
"EventType": {
|
| 997 |
+
"Ref": "LambdaEventType"
|
| 998 |
+
},
|
| 999 |
+
"LambdaFunctionARN": {
|
| 1000 |
+
"Ref": "LambdaEdgeVersion"
|
| 1001 |
+
}
|
| 1002 |
+
}
|
| 1003 |
+
]
|
| 1004 |
+
},
|
| 1005 |
+
"PriceClass": {
|
| 1006 |
+
"Ref": "PriceClass"
|
| 1007 |
+
},
|
| 1008 |
+
"ViewerCertificate": {
|
| 1009 |
+
"AcmCertificateArn": {
|
| 1010 |
+
"Fn::Sub": "arn:${AWS::Partition}:acm:${AWS::Region}:${AWS::AccountId}:certificate/${ACMCertificateIdentifier}"
|
| 1011 |
+
},
|
| 1012 |
+
"SslSupportMethod": {
|
| 1013 |
+
"Ref": "SslSupportMethod"
|
| 1014 |
+
},
|
| 1015 |
+
"MinimumProtocolVersion": {
|
| 1016 |
+
"Ref": "MinimumProtocolVersion"
|
| 1017 |
+
}
|
| 1018 |
+
},
|
| 1019 |
+
"IPV6Enabled": {
|
| 1020 |
+
"Ref": "IPV6Enabled"
|
| 1021 |
+
},
|
| 1022 |
+
"Logging": {
|
| 1023 |
+
"Bucket": {
|
| 1024 |
+
"Fn::Sub": "${LoggingBucket}.s3.amazonaws.com"
|
| 1025 |
+
}
|
| 1026 |
+
}
|
| 1027 |
+
}
|
| 1028 |
+
}
|
| 1029 |
+
},
|
| 1030 |
+
"LambdaEdgeFunction": {
|
| 1031 |
+
"Type": "AWS::Lambda::Function",
|
| 1032 |
+
"Metadata": {
|
| 1033 |
+
"guard": {
|
| 1034 |
+
"SuppressedRules": [
|
| 1035 |
+
"LAMBDA_INSIDE_VPC"
|
| 1036 |
+
]
|
| 1037 |
+
}
|
| 1038 |
+
},
|
| 1039 |
+
"Properties": {
|
| 1040 |
+
"Description": "A custom Lambda@Edge function for serving custom headers from CloudFront Distribution",
|
| 1041 |
+
"FunctionName": {
|
| 1042 |
+
"Fn::Sub": "${AppName}-lambda-edge-${Environment}"
|
| 1043 |
+
},
|
| 1044 |
+
"Handler": "index.handler",
|
| 1045 |
+
"Role": {
|
| 1046 |
+
"Fn::GetAtt": [
|
| 1047 |
+
"LambdaEdgeIAMRole",
|
| 1048 |
+
"Arn"
|
| 1049 |
+
]
|
| 1050 |
+
},
|
| 1051 |
+
"MemorySize": 128,
|
| 1052 |
+
"Timeout": 5,
|
| 1053 |
+
"Code": {
|
| 1054 |
+
"ZipFile": "'use strict';\n\n exports.handler = (event, context, callback) => {\n console.log('Adding additional headers to CloudFront response.');\n\n const response = event.Records[0].cf.response;\n response.headers['strict-transport-security'] = [{\n key: 'Strict-Transport-Security',\n value: 'max-age=86400; includeSubdomains; preload',\n }];\n response.headers['x-content-type-options'] = [{\n key: 'X-Content-Type-Options',\n value: 'nosniff',\n }];\n response.headers['x-frame-options'] = [{\n key: 'X-Frame-Options',\n value: \"DENY\"\n }];\n response.headers['content-security-policy'] = [{\n key: 'Content-Security-Policy',\n value: \"default-src 'none'; img-src 'self'; script-src 'self'; style-src 'self'; object-src 'none'\"\n }];\n response.headers['x-xss-protection'] = [{\n key: 'X-XSS-Protection',\n value: \"1; mode=block\"\n }];\n response.headers['referrer-policy'] = [{\n key: 'Referrer-Policy',\n value: \"same-origin\"\n }];\n callback(null, response);\n };\n"
|
| 1055 |
+
},
|
| 1056 |
+
"Runtime": "nodejs20.x"
|
| 1057 |
+
}
|
| 1058 |
+
},
|
| 1059 |
+
"LambdaEdgeVersion": {
|
| 1060 |
+
"Type": "AWS::Lambda::Version",
|
| 1061 |
+
"Properties": {
|
| 1062 |
+
"FunctionName": {
|
| 1063 |
+
"Ref": "LambdaEdgeFunction"
|
| 1064 |
+
}
|
| 1065 |
+
}
|
| 1066 |
+
}
|
| 1067 |
+
},
|
| 1068 |
+
"Outputs": {
|
| 1069 |
+
"AdministratorAccessIAMRole": {
|
| 1070 |
+
"Description": "Administrator Access IAM Role",
|
| 1071 |
+
"Value": {
|
| 1072 |
+
"Ref": "AdministratorAccessIAMRole"
|
| 1073 |
+
},
|
| 1074 |
+
"Export": {
|
| 1075 |
+
"Name": {
|
| 1076 |
+
"Fn::Sub": "${AppName}-iam-${Environment}-administrator-access-role"
|
| 1077 |
+
}
|
| 1078 |
+
}
|
| 1079 |
+
},
|
| 1080 |
+
"LoggingBucket": {
|
| 1081 |
+
"Description": "Name of S3 Logging bucket",
|
| 1082 |
+
"Value": {
|
| 1083 |
+
"Ref": "LoggingBucket"
|
| 1084 |
+
},
|
| 1085 |
+
"Export": {
|
| 1086 |
+
"Name": {
|
| 1087 |
+
"Fn::Sub": "${AppName}-logging-${Environment}-${AWS::AccountId}-${AWS::Region}"
|
| 1088 |
+
}
|
| 1089 |
+
}
|
| 1090 |
+
},
|
| 1091 |
+
"LoggingBucketKMSKey": {
|
| 1092 |
+
"Description": "Logging Bucket KMS Key",
|
| 1093 |
+
"Value": {
|
| 1094 |
+
"Ref": "LoggingBucketKMSKey"
|
| 1095 |
+
},
|
| 1096 |
+
"Export": {
|
| 1097 |
+
"Name": {
|
| 1098 |
+
"Fn::Sub": "${AppName}-${Environment}-s3-logging-kms"
|
| 1099 |
+
}
|
| 1100 |
+
}
|
| 1101 |
+
},
|
| 1102 |
+
"OriginALB": {
|
| 1103 |
+
"Description": "The URL of the Origin ALB",
|
| 1104 |
+
"Value": {
|
| 1105 |
+
"Fn::GetAtt": [
|
| 1106 |
+
"OriginALB",
|
| 1107 |
+
"DNSName"
|
| 1108 |
+
]
|
| 1109 |
+
},
|
| 1110 |
+
"Export": {
|
| 1111 |
+
"Name": {
|
| 1112 |
+
"Fn::Sub": "${AppName}-${Environment}-origin-alb-dns"
|
| 1113 |
+
}
|
| 1114 |
+
}
|
| 1115 |
+
},
|
| 1116 |
+
"ALBExternalAccessSGID": {
|
| 1117 |
+
"Description": "ALB External Access Security Group ID",
|
| 1118 |
+
"Value": {
|
| 1119 |
+
"Ref": "ALBExternalAccessSG"
|
| 1120 |
+
},
|
| 1121 |
+
"Export": {
|
| 1122 |
+
"Name": {
|
| 1123 |
+
"Fn::Sub": "${AppName}-${Environment}-alb-external-access-ingrees-sg"
|
| 1124 |
+
}
|
| 1125 |
+
}
|
| 1126 |
+
},
|
| 1127 |
+
"EC2InstanceSGID": {
|
| 1128 |
+
"Description": "EC2 Instance Security Group ID",
|
| 1129 |
+
"Value": {
|
| 1130 |
+
"Ref": "EC2InstanceSG"
|
| 1131 |
+
},
|
| 1132 |
+
"Export": {
|
| 1133 |
+
"Name": {
|
| 1134 |
+
"Fn::Sub": "${AppName}-${Environment}-ec2-instance-sg"
|
| 1135 |
+
}
|
| 1136 |
+
}
|
| 1137 |
+
},
|
| 1138 |
+
"EC2InstanceDNS": {
|
| 1139 |
+
"Description": "EC2 Instance DNS Name",
|
| 1140 |
+
"Value": {
|
| 1141 |
+
"Fn::GetAtt": [
|
| 1142 |
+
"EC2Instance",
|
| 1143 |
+
"PrivateDnsName"
|
| 1144 |
+
]
|
| 1145 |
+
},
|
| 1146 |
+
"Export": {
|
| 1147 |
+
"Name": {
|
| 1148 |
+
"Fn::Sub": "${AppName}-${Environment}-ec2-instance-dns"
|
| 1149 |
+
}
|
| 1150 |
+
}
|
| 1151 |
+
},
|
| 1152 |
+
"EC2InstanceIP": {
|
| 1153 |
+
"Description": "EC2 Instance IP Address",
|
| 1154 |
+
"Value": {
|
| 1155 |
+
"Fn::GetAtt": [
|
| 1156 |
+
"EC2Instance",
|
| 1157 |
+
"PrivateIp"
|
| 1158 |
+
]
|
| 1159 |
+
},
|
| 1160 |
+
"Export": {
|
| 1161 |
+
"Name": {
|
| 1162 |
+
"Fn::Sub": "${AppName}-${Environment}-ec2-instance-ip-address"
|
| 1163 |
+
}
|
| 1164 |
+
}
|
| 1165 |
+
},
|
| 1166 |
+
"EC2InstanceID": {
|
| 1167 |
+
"Description": "EC2 Instance Instance ID",
|
| 1168 |
+
"Value": {
|
| 1169 |
+
"Ref": "EC2Instance"
|
| 1170 |
+
},
|
| 1171 |
+
"Export": {
|
| 1172 |
+
"Name": {
|
| 1173 |
+
"Fn::Sub": "${AppName}-${Environment}-ec2-instance-id"
|
| 1174 |
+
}
|
| 1175 |
+
}
|
| 1176 |
+
},
|
| 1177 |
+
"CloudFrontEndpoint": {
|
| 1178 |
+
"Description": "Endpoint for Cloudfront Distribution",
|
| 1179 |
+
"Value": {
|
| 1180 |
+
"Ref": "CloudFrontDistribution"
|
| 1181 |
+
},
|
| 1182 |
+
"Export": {
|
| 1183 |
+
"Name": {
|
| 1184 |
+
"Fn::Sub": "${AppName}-${Environment}-cloudfront-distribution"
|
| 1185 |
+
}
|
| 1186 |
+
}
|
| 1187 |
+
},
|
| 1188 |
+
"AlternateDomainNames": {
|
| 1189 |
+
"Description": "Alternate Domain Names (CNAME)",
|
| 1190 |
+
"Value": {
|
| 1191 |
+
"Ref": "AlternateDomainNames"
|
| 1192 |
+
}
|
| 1193 |
+
},
|
| 1194 |
+
"LambdaEdgeFunction": {
|
| 1195 |
+
"Description": "The Name of the Lambda@Edge Function",
|
| 1196 |
+
"Value": "LambdaEdgeFunction",
|
| 1197 |
+
"Export": {
|
| 1198 |
+
"Name": {
|
| 1199 |
+
"Fn::Sub": "${AppName}-${Environment}-lambda-edge-function-3"
|
| 1200 |
+
}
|
| 1201 |
+
}
|
| 1202 |
+
},
|
| 1203 |
+
"LambdaEdgeFunctionARN": {
|
| 1204 |
+
"Description": "The ARN of the Lambda@Edge Function",
|
| 1205 |
+
"Value": {
|
| 1206 |
+
"Fn::GetAtt": [
|
| 1207 |
+
"LambdaEdgeFunction",
|
| 1208 |
+
"Arn"
|
| 1209 |
+
]
|
| 1210 |
+
},
|
| 1211 |
+
"Export": {
|
| 1212 |
+
"Name": {
|
| 1213 |
+
"Fn::Sub": "${AppName}-${Environment}-lambda-edge-function-arn-3"
|
| 1214 |
+
}
|
| 1215 |
+
}
|
| 1216 |
+
},
|
| 1217 |
+
"LambdaEdgeVersion": {
|
| 1218 |
+
"Description": "Lambda@Edge Version Function",
|
| 1219 |
+
"Value": {
|
| 1220 |
+
"Fn::GetAtt": [
|
| 1221 |
+
"LambdaEdgeVersion",
|
| 1222 |
+
"Version"
|
| 1223 |
+
]
|
| 1224 |
+
}
|
| 1225 |
+
}
|
| 1226 |
+
}
|
| 1227 |
+
}
|
human_reference_dataset/aws-cloudformation-templates/Solutions/CloudFrontCustomOriginLambda@Edge/CloudFront.yaml
ADDED
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
AWSTemplateFormatVersion: "2010-09-09"
|
| 2 |
+
|
| 3 |
+
Description: 'CI/CD optimized AWS CloudFormation Sample Template for AWS CloudFront Distribution with Custom Origin with an example of using the AWS Application Load Balancer (ALB) and a basic Amazon EC2 Instance. AWS CloudFront Distribution is associated with Lambda@Edge for Security Headers inspection. In addition, AWS CloudFormation Template will provision an Examples of necessary IAM, S3, KMS and Security Groups resources. ### Before deployment please make sure that all parameters are reviewed and updated according the specific use case. ### **WARNING** This template creates one Amazon EC2 instance and an Application Load Balancer, KMS Keys, S3 bucket, CloudFront Distribution resources. You will be billed for the AWS resources used if you create a stack from this template.'
|
| 4 |
+
|
| 5 |
+
Metadata:
|
| 6 |
+
cfn-lint:
|
| 7 |
+
config:
|
| 8 |
+
regions:
|
| 9 |
+
- us-east-1
|
| 10 |
+
- us-west-2
|
| 11 |
+
|
| 12 |
+
Parameters:
|
| 13 |
+
Environment:
|
| 14 |
+
Description: Please specify the target environment.
|
| 15 |
+
Type: String
|
| 16 |
+
AllowedValues:
|
| 17 |
+
- prod
|
| 18 |
+
- staging
|
| 19 |
+
- dev
|
| 20 |
+
- qa
|
| 21 |
+
Default: dev
|
| 22 |
+
|
| 23 |
+
VpcId:
|
| 24 |
+
Description: Please specify the VPC ID.
|
| 25 |
+
Type: AWS::EC2::VPC::Id
|
| 26 |
+
ConstraintDescription: "Must be a valid VPC ID"
|
| 27 |
+
|
| 28 |
+
PublicSubnetId1:
|
| 29 |
+
Description: Please specify first public subnet ID.
|
| 30 |
+
Type: AWS::EC2::Subnet::Id
|
| 31 |
+
ConstraintDescription: "Must be a valid subnet ID in the selected VPC"
|
| 32 |
+
|
| 33 |
+
PublicSubnetId2:
|
| 34 |
+
Description: Please specify second public subnet ID.
|
| 35 |
+
Type: AWS::EC2::Subnet::Id
|
| 36 |
+
ConstraintDescription: "Must be a valid subnet ID in the selected VPC"
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
AppName:
|
| 40 |
+
Description: Application environment name.
|
| 41 |
+
Type: String
|
| 42 |
+
Default: example
|
| 43 |
+
|
| 44 |
+
AlternateDomainNames:
|
| 45 |
+
Description: CNAMEs (alternate domain names), if any, for the distribution. Example. mydomain.com
|
| 46 |
+
Type: String
|
| 47 |
+
Default: name.domain.com
|
| 48 |
+
|
| 49 |
+
ACMCertificateIdentifier:
|
| 50 |
+
Description: The AWS Certificate Manager (ACM) certificate identifier.
|
| 51 |
+
Type: String
|
| 52 |
+
Default: 1234567890abcdefgh
|
| 53 |
+
|
| 54 |
+
LambdaEventType:
|
| 55 |
+
Description: Please specify the event type that triggers a Lambda function invocation.
|
| 56 |
+
Type: String
|
| 57 |
+
AllowedValues:
|
| 58 |
+
- viewer-request
|
| 59 |
+
- origin-request
|
| 60 |
+
- origin-response
|
| 61 |
+
- viewer-response
|
| 62 |
+
Default: viewer-response
|
| 63 |
+
|
| 64 |
+
IPV6Enabled:
|
| 65 |
+
Description: Should CloudFront to respond to IPv6 DNS requests with an IPv6 address for your distribution.
|
| 66 |
+
Type: String
|
| 67 |
+
AllowedValues:
|
| 68 |
+
- "true"
|
| 69 |
+
- "false"
|
| 70 |
+
Default: "true"
|
| 71 |
+
|
| 72 |
+
EC2ImageId:
|
| 73 |
+
Description: EC2 AMI Id
|
| 74 |
+
Type: AWS::EC2::Image::Id
|
| 75 |
+
Default: ami-0d85a662720db9789
|
| 76 |
+
|
| 77 |
+
EC2InstanceType:
|
| 78 |
+
Description: Amazon EC2 instance type.
|
| 79 |
+
Type: String
|
| 80 |
+
AllowedValues:
|
| 81 |
+
- t2.small
|
| 82 |
+
- t2.medium
|
| 83 |
+
- t2.large
|
| 84 |
+
- t2.xlarge
|
| 85 |
+
- t2.2xlarge
|
| 86 |
+
- m4.large
|
| 87 |
+
- m4.xlarge
|
| 88 |
+
- m4.2xlarge
|
| 89 |
+
- m4.4xlarge
|
| 90 |
+
- m4.10xlarge
|
| 91 |
+
- m4.16xlarge
|
| 92 |
+
- m5.large
|
| 93 |
+
- m5.xlarge
|
| 94 |
+
- m5.2xlarge
|
| 95 |
+
- m5.4xlarge
|
| 96 |
+
- m5.12xlarge
|
| 97 |
+
- m5.24xlarge
|
| 98 |
+
- m5d.large
|
| 99 |
+
- m5d.xlarge
|
| 100 |
+
- m5d.2xlarge
|
| 101 |
+
- m5d.4xlarge
|
| 102 |
+
- m5d.12xlarge
|
| 103 |
+
- m5d.24xlarge
|
| 104 |
+
Default: t2.small
|
| 105 |
+
|
| 106 |
+
KeyPairName:
|
| 107 |
+
Description: EC2 KeyPair.
|
| 108 |
+
Type: AWS::EC2::KeyPair::KeyName
|
| 109 |
+
ConstraintDescription: "Must be the name of an existing EC2 KeyPair"
|
| 110 |
+
|
| 111 |
+
BootVolSize:
|
| 112 |
+
Description: EC2 Instance Boot volume size.
|
| 113 |
+
Type: String
|
| 114 |
+
Default: "100"
|
| 115 |
+
|
| 116 |
+
BootVolType:
|
| 117 |
+
Description: EC2 Instance Boot volume type.
|
| 118 |
+
Type: String
|
| 119 |
+
AllowedValues:
|
| 120 |
+
- gp2
|
| 121 |
+
- io1
|
| 122 |
+
- sc1
|
| 123 |
+
- st1
|
| 124 |
+
Default: gp2
|
| 125 |
+
|
| 126 |
+
ALBType:
|
| 127 |
+
Description: AWS Load Balancer Type.
|
| 128 |
+
Type: String
|
| 129 |
+
AllowedValues:
|
| 130 |
+
- application
|
| 131 |
+
- network
|
| 132 |
+
Default: application
|
| 133 |
+
|
| 134 |
+
OriginALBTGPort:
|
| 135 |
+
Description: Port number the application is running on, for Origin ALB Target Group and Health Check port.
|
| 136 |
+
Type: String
|
| 137 |
+
Default: "8080"
|
| 138 |
+
|
| 139 |
+
OriginProtocolPolicy:
|
| 140 |
+
Description: CloudFront Origin Protocol Policy to apply to your origin.
|
| 141 |
+
Type: String
|
| 142 |
+
AllowedValues:
|
| 143 |
+
- http-only
|
| 144 |
+
- match-viewer
|
| 145 |
+
- https-only
|
| 146 |
+
Default: http-only
|
| 147 |
+
|
| 148 |
+
Compress:
|
| 149 |
+
Description: 'CloudFront should support gzip compression requests: Accept-Encoding: gzip.'
|
| 150 |
+
Type: String
|
| 151 |
+
AllowedValues:
|
| 152 |
+
- "true"
|
| 153 |
+
- "false"
|
| 154 |
+
Default: "false"
|
| 155 |
+
|
| 156 |
+
DefaultTTL:
|
| 157 |
+
Description: The default time in seconds that objects stay in CloudFront caches before CloudFront forwards another request to your custom origin. By default, AWS CloudFormation specifies 86400 seconds (one day).
|
| 158 |
+
Type: String
|
| 159 |
+
Default: "0"
|
| 160 |
+
|
| 161 |
+
MaxTTL:
|
| 162 |
+
Description: The maximum time in seconds that objects stay in CloudFront caches before CloudFront forwards another request to your custom origin. By default, AWS CloudFormation specifies 31536000 seconds (one year).
|
| 163 |
+
Type: String
|
| 164 |
+
Default: "0"
|
| 165 |
+
|
| 166 |
+
MinTTL:
|
| 167 |
+
Description: The minimum amount of time that you want objects to stay in the cache before CloudFront queries your origin to see whether the object has been updated.
|
| 168 |
+
Type: String
|
| 169 |
+
Default: "0"
|
| 170 |
+
|
| 171 |
+
QueryString:
|
| 172 |
+
Description: CIndicates whether you want CloudFront to forward query strings to the origin that is associated with this cache behavior.
|
| 173 |
+
Type: String
|
| 174 |
+
AllowedValues:
|
| 175 |
+
- "true"
|
| 176 |
+
- "false"
|
| 177 |
+
Default: "true"
|
| 178 |
+
|
| 179 |
+
ForwardCookies:
|
| 180 |
+
Description: Forwards specified cookies to the origin of the cache behavior.
|
| 181 |
+
Type: String
|
| 182 |
+
AllowedValues:
|
| 183 |
+
- all
|
| 184 |
+
- whitelist
|
| 185 |
+
- none
|
| 186 |
+
Default: all
|
| 187 |
+
|
| 188 |
+
ViewerProtocolPolicy:
|
| 189 |
+
Description: The protocol that users can use to access the files in the origin that you specified in the TargetOriginId property when the default cache behavior is applied to a request.
|
| 190 |
+
Type: String
|
| 191 |
+
AllowedValues:
|
| 192 |
+
- redirect-to-https
|
| 193 |
+
- allow-all
|
| 194 |
+
- https-only
|
| 195 |
+
Default: redirect-to-https
|
| 196 |
+
|
| 197 |
+
PriceClass:
|
| 198 |
+
Description: The price class that corresponds with the maximum price that you want to pay for CloudFront service. If you specify PriceClass_All, CloudFront responds to requests for your objects from all CloudFront edge locations.
|
| 199 |
+
Type: String
|
| 200 |
+
AllowedValues:
|
| 201 |
+
- PriceClass_All
|
| 202 |
+
- PriceClass_100
|
| 203 |
+
- PriceClass_200
|
| 204 |
+
Default: PriceClass_All
|
| 205 |
+
|
| 206 |
+
SslSupportMethod:
|
| 207 |
+
Description: Specifies how CloudFront serves HTTPS requests.
|
| 208 |
+
Type: String
|
| 209 |
+
AllowedValues:
|
| 210 |
+
- sni-only
|
| 211 |
+
- vip
|
| 212 |
+
Default: sni-only
|
| 213 |
+
|
| 214 |
+
MinimumProtocolVersion:
|
| 215 |
+
Description: The minimum version of the SSL protocol that you want CloudFront to use for HTTPS connections.
|
| 216 |
+
Type: String
|
| 217 |
+
AllowedValues:
|
| 218 |
+
- TLSv1
|
| 219 |
+
- TLSv1.2_2018
|
| 220 |
+
- TLSv1.1_2016
|
| 221 |
+
- TLSv1_2016
|
| 222 |
+
- SSLv3
|
| 223 |
+
Default: TLSv1
|
| 224 |
+
|
| 225 |
+
OriginKeepaliveTimeout:
|
| 226 |
+
Description: You can create a custom keep-alive timeout. All timeout units are in seconds. The default keep-alive timeout is 5 seconds, but you can configure custom timeout lengths. The minimum timeout length is 1 second; the maximum is 60 seconds.
|
| 227 |
+
Type: String
|
| 228 |
+
Default: "60"
|
| 229 |
+
|
| 230 |
+
OriginReadTimeout:
|
| 231 |
+
Description: You can create a custom origin read timeout. All timeout units are in seconds. The default origin read timeout is 30 seconds, but you can configure custom timeout lengths. The minimum timeout length is 4 seconds; the maximum is 60 seconds.
|
| 232 |
+
Type: String
|
| 233 |
+
Default: "30"
|
| 234 |
+
|
| 235 |
+
ALBScheme:
|
| 236 |
+
Description: Origin ALB scheme.
|
| 237 |
+
Type: String
|
| 238 |
+
AllowedValues:
|
| 239 |
+
- internet-facing
|
| 240 |
+
- internal
|
| 241 |
+
Default: internet-facing
|
| 242 |
+
|
| 243 |
+
ALBTargetGroupHealthCheckIntervalSeconds:
|
| 244 |
+
Description: Origin ALB Target Group Health Check Interval in Seconds.
|
| 245 |
+
Type: String
|
| 246 |
+
Default: "30"
|
| 247 |
+
|
| 248 |
+
ALBTargetGroupHealthCheckTimeoutSeconds:
|
| 249 |
+
Description: Origin ALB Target Group Health Check Timeout in Seconds.
|
| 250 |
+
Type: String
|
| 251 |
+
Default: "5"
|
| 252 |
+
|
| 253 |
+
ALBTargetGroupHealthyThresholdCount:
|
| 254 |
+
Description: Origin ALB Target Group Healthy Threshold Count.
|
| 255 |
+
Type: String
|
| 256 |
+
Default: "5"
|
| 257 |
+
|
| 258 |
+
ALBTargetGroupUnhealthyThresholdCount:
|
| 259 |
+
Description: Origin ALB Target Group Unhealthy Threshold Count.
|
| 260 |
+
Type: String
|
| 261 |
+
Default: "2"
|
| 262 |
+
|
| 263 |
+
ALBAttributeIdleTimeOut:
|
| 264 |
+
Description: Origin ALB Target Group Unhealthy Threshold Count.
|
| 265 |
+
Type: String
|
| 266 |
+
Default: "60"
|
| 267 |
+
|
| 268 |
+
ALBAttributeDeletionProtection:
|
| 269 |
+
Description: Origin ALB Target Group Unhealthy Threshold Count.
|
| 270 |
+
Type: String
|
| 271 |
+
AllowedValues:
|
| 272 |
+
- "true"
|
| 273 |
+
- "false"
|
| 274 |
+
Default: "false"
|
| 275 |
+
|
| 276 |
+
ALBAttributeRoutingHttp2:
|
| 277 |
+
Description: Origin ALB Target Group Unhealthy Threshold Count.
|
| 278 |
+
Type: String
|
| 279 |
+
AllowedValues:
|
| 280 |
+
- "true"
|
| 281 |
+
- "false"
|
| 282 |
+
Default: "true"
|
| 283 |
+
|
| 284 |
+
ALBTargetGroupAttributeDeregistration:
|
| 285 |
+
Description: Origin ALB Target Group Deregistration Timeout.
|
| 286 |
+
Type: String
|
| 287 |
+
Default: "300"
|
| 288 |
+
|
| 289 |
+
HealthCheckProtocol:
|
| 290 |
+
Description: Origin ALB Target Group Health Check Protocol.
|
| 291 |
+
Type: String
|
| 292 |
+
AllowedValues:
|
| 293 |
+
- HTTPS
|
| 294 |
+
- HTTP
|
| 295 |
+
Default: HTTP
|
| 296 |
+
|
| 297 |
+
HealthCheckPath:
|
| 298 |
+
Description: Origin ALB Target Group Health Check Path.
|
| 299 |
+
Type: String
|
| 300 |
+
Default: /health.html
|
| 301 |
+
|
| 302 |
+
LoggingBucketVersioning:
|
| 303 |
+
Description: The versioning state of an Amazon S3 bucket. If you enable versioning, you must suspend versioning to disable it.
|
| 304 |
+
Type: String
|
| 305 |
+
AllowedValues:
|
| 306 |
+
- Enabled
|
| 307 |
+
- Suspended
|
| 308 |
+
Default: Suspended
|
| 309 |
+
|
| 310 |
+
Resources:
|
| 311 |
+
|
| 312 |
+
# IAM ROLE USED FOR LOGGING KMS KEY ACCESS
|
| 313 |
+
AdministratorAccessIAMRole:
|
| 314 |
+
Type: AWS::IAM::Role
|
| 315 |
+
Properties:
|
| 316 |
+
RoleName: !Sub AdministratorAccess-${AppName}
|
| 317 |
+
ManagedPolicyArns:
|
| 318 |
+
- !Sub arn:${AWS::Partition}:iam::aws:policy/AdministratorAccess
|
| 319 |
+
AssumeRolePolicyDocument:
|
| 320 |
+
Version: "2012-10-17"
|
| 321 |
+
Statement:
|
| 322 |
+
- Effect: Allow
|
| 323 |
+
Principal:
|
| 324 |
+
Service:
|
| 325 |
+
- ec2.amazonaws.com
|
| 326 |
+
Action:
|
| 327 |
+
- sts:AssumeRole
|
| 328 |
+
Path: /
|
| 329 |
+
|
| 330 |
+
# IAM ROLE USED FOR LAMBDA EDGE
|
| 331 |
+
LambdaEdgeIAMRole:
|
| 332 |
+
Type: AWS::IAM::Role
|
| 333 |
+
Properties:
|
| 334 |
+
RoleName: !Sub ${AppName}-iam-lambda-edge-role-${Environment}
|
| 335 |
+
AssumeRolePolicyDocument:
|
| 336 |
+
Version: "2012-10-17"
|
| 337 |
+
Statement:
|
| 338 |
+
- Sid: AllowLambdaServiceToAssumeRole
|
| 339 |
+
Effect: Allow
|
| 340 |
+
Principal:
|
| 341 |
+
Service:
|
| 342 |
+
- edgelambda.amazonaws.com
|
| 343 |
+
- lambda.amazonaws.com
|
| 344 |
+
Action:
|
| 345 |
+
- sts:AssumeRole
|
| 346 |
+
ManagedPolicyArns:
|
| 347 |
+
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
|
| 348 |
+
- arn:aws:iam::aws:policy/AWSXrayWriteOnlyAccess
|
| 349 |
+
Path: /
|
| 350 |
+
Policies:
|
| 351 |
+
- PolicyName: PublishNewLambdaEdgeVersion
|
| 352 |
+
PolicyDocument:
|
| 353 |
+
Version: "2012-10-17"
|
| 354 |
+
Statement:
|
| 355 |
+
- Effect: Allow
|
| 356 |
+
Action:
|
| 357 |
+
- lambda:PublishVersion
|
| 358 |
+
Resource: '*'
|
| 359 |
+
|
| 360 |
+
# KMS KEY USED FOR LOGGING S3 BUCKET
|
| 361 |
+
LoggingBucketKMSKey:
|
| 362 |
+
Type: AWS::KMS::Key
|
| 363 |
+
DependsOn: AdministratorAccessIAMRole
|
| 364 |
+
Properties:
|
| 365 |
+
Description: Logging S3 Bucket KMS Key
|
| 366 |
+
Enabled: true
|
| 367 |
+
EnableKeyRotation: true
|
| 368 |
+
KeyPolicy:
|
| 369 |
+
Version: "2012-10-17"
|
| 370 |
+
Statement:
|
| 371 |
+
- Sid: Enable IAM policies to allow access to the Key
|
| 372 |
+
Effect: Allow
|
| 373 |
+
Principal:
|
| 374 |
+
AWS: !Sub arn:${AWS::Partition}:iam::${AWS::AccountId}:root
|
| 375 |
+
Action:
|
| 376 |
+
- kms:*
|
| 377 |
+
Resource: '*'
|
| 378 |
+
- Sid: Allow administration of the key
|
| 379 |
+
Effect: Allow
|
| 380 |
+
Principal:
|
| 381 |
+
AWS:
|
| 382 |
+
- !Sub arn:${AWS::Partition}:iam::${AWS::AccountId}:role/AdministratorAccess-${AppName}
|
| 383 |
+
Action:
|
| 384 |
+
- kms:Put*
|
| 385 |
+
- kms:ScheduleKeyDeletion
|
| 386 |
+
- kms:CancelKeyDeletion
|
| 387 |
+
- kms:Describe*
|
| 388 |
+
- kms:Revoke*
|
| 389 |
+
- kms:Disable*
|
| 390 |
+
- kms:Enable*
|
| 391 |
+
- kms:Delete*
|
| 392 |
+
- kms:List*
|
| 393 |
+
- kms:Update*
|
| 394 |
+
- kms:Create*
|
| 395 |
+
Resource: '*'
|
| 396 |
+
|
| 397 |
+
# KMS KEY ALIAS USED FOR LOGGING BUCKET
|
| 398 |
+
LoggingBucketKMSKeyAlias:
|
| 399 |
+
Type: AWS::KMS::Alias
|
| 400 |
+
Properties:
|
| 401 |
+
AliasName: !Sub alias/${AppName}/${Environment}/s3-logging-kms
|
| 402 |
+
TargetKeyId: !Sub ${LoggingBucketKMSKey}
|
| 403 |
+
|
| 404 |
+
# LOGGING S3 BUCKET
|
| 405 |
+
LoggingBucket:
|
| 406 |
+
DeletionPolicy: Retain
|
| 407 |
+
UpdateReplacePolicy: Retain
|
| 408 |
+
Type: AWS::S3::Bucket
|
| 409 |
+
DependsOn: LoggingBucketKMSKey
|
| 410 |
+
Metadata:
|
| 411 |
+
guard:
|
| 412 |
+
SuppressedRules:
|
| 413 |
+
- S3_BUCKET_DEFAULT_LOCK_ENABLED
|
| 414 |
+
- S3_BUCKET_VERSIONING_ENABLED
|
| 415 |
+
- S3_BUCKET_REPLICATION_ENABLED
|
| 416 |
+
- S3_BUCKET_LOGGING_ENABLED
|
| 417 |
+
Properties:
|
| 418 |
+
BucketName: !Sub ${AppName}-logging-${Environment}-${AWS::AccountId}-${AWS::Region}
|
| 419 |
+
OwnershipControls:
|
| 420 |
+
Rules:
|
| 421 |
+
- ObjectOwnership: ObjectWriter
|
| 422 |
+
PublicAccessBlockConfiguration:
|
| 423 |
+
BlockPublicAcls: true
|
| 424 |
+
BlockPublicPolicy: true
|
| 425 |
+
IgnorePublicAcls: true
|
| 426 |
+
RestrictPublicBuckets: true
|
| 427 |
+
AccessControl: LogDeliveryWrite
|
| 428 |
+
BucketEncryption:
|
| 429 |
+
ServerSideEncryptionConfiguration:
|
| 430 |
+
- ServerSideEncryptionByDefault:
|
| 431 |
+
KMSMasterKeyID: !GetAtt LoggingBucketKMSKey.Arn
|
| 432 |
+
SSEAlgorithm: aws:kms
|
| 433 |
+
VersioningConfiguration:
|
| 434 |
+
Status: !Ref LoggingBucketVersioning
|
| 435 |
+
|
| 436 |
+
# LOGGING S3 BUCKET POLICY
|
| 437 |
+
LoggingBucketPolicy:
|
| 438 |
+
Type: AWS::S3::BucketPolicy
|
| 439 |
+
Properties:
|
| 440 |
+
Bucket: !Ref LoggingBucket
|
| 441 |
+
PolicyDocument:
|
| 442 |
+
Version: "2012-10-17"
|
| 443 |
+
Statement:
|
| 444 |
+
- Sid: LoggingBucketPermissions
|
| 445 |
+
Effect: Allow
|
| 446 |
+
Principal:
|
| 447 |
+
AWS: !Sub arn:${AWS::Partition}:iam::${AWS::AccountId}:root
|
| 448 |
+
Action: s3:PutObject
|
| 449 |
+
Resource:
|
| 450 |
+
- !Sub arn:${AWS::Partition}:s3:::${LoggingBucket}/AWSLogs/${AWS::AccountId}/*
|
| 451 |
+
- Action: s3:*
|
| 452 |
+
Condition:
|
| 453 |
+
Bool:
|
| 454 |
+
aws:SecureTransport: false
|
| 455 |
+
Effect: Deny
|
| 456 |
+
Principal:
|
| 457 |
+
AWS: '*'
|
| 458 |
+
Resource:
|
| 459 |
+
- !Sub arn:${AWS::Partition}:s3:::${LoggingBucket}/AWSLogs/${AWS::AccountId}/*
|
| 460 |
+
|
| 461 |
+
# EC2 INSTANCE
|
| 462 |
+
EC2Instance:
|
| 463 |
+
Type: AWS::EC2::Instance
|
| 464 |
+
Properties:
|
| 465 |
+
ImageId: !Ref EC2ImageId
|
| 466 |
+
InstanceType: !Ref EC2InstanceType
|
| 467 |
+
SubnetId: !Ref PublicSubnetId1
|
| 468 |
+
BlockDeviceMappings:
|
| 469 |
+
- DeviceName: /dev/sda1
|
| 470 |
+
Ebs:
|
| 471 |
+
VolumeSize: !Ref BootVolSize
|
| 472 |
+
VolumeType: !Ref BootVolType
|
| 473 |
+
SecurityGroupIds:
|
| 474 |
+
- !Ref EC2InstanceSG
|
| 475 |
+
- !Ref ALBExternalAccessSG
|
| 476 |
+
KeyName: !Ref KeyPairName
|
| 477 |
+
Tags:
|
| 478 |
+
- Key: Name
|
| 479 |
+
Value: !Sub ${AppName}-${Environment}-ec2-instance
|
| 480 |
+
- Key: Environment
|
| 481 |
+
Value: !Ref Environment
|
| 482 |
+
|
| 483 |
+
# EC2 INSTANCE SECURITY GROUP
|
| 484 |
+
EC2InstanceSG:
|
| 485 |
+
Type: AWS::EC2::SecurityGroup
|
| 486 |
+
Properties:
|
| 487 |
+
GroupDescription: EC2 Instance Security Group
|
| 488 |
+
VpcId: !Ref VpcId
|
| 489 |
+
Tags:
|
| 490 |
+
- Key: Name
|
| 491 |
+
Value: !Sub ${AppName}-${Environment}-ec2-instance-SG
|
| 492 |
+
- Key: Environment
|
| 493 |
+
Value: !Ref Environment
|
| 494 |
+
|
| 495 |
+
# SECURITY GROUP INGRESS
|
| 496 |
+
Tcp8080In:
|
| 497 |
+
Type: AWS::EC2::SecurityGroupIngress
|
| 498 |
+
Properties:
|
| 499 |
+
GroupId: !Ref EC2InstanceSG
|
| 500 |
+
ToPort: "8080"
|
| 501 |
+
IpProtocol: tcp
|
| 502 |
+
FromPort: "8080"
|
| 503 |
+
SourceSecurityGroupId: !Ref ALBExternalAccessSG
|
| 504 |
+
|
| 505 |
+
# ORIGIN ALB
|
| 506 |
+
OriginALB:
|
| 507 |
+
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
|
| 508 |
+
Properties:
|
| 509 |
+
Name: !Sub ${AppName}-${Environment}-alb
|
| 510 |
+
Scheme: !Ref ALBScheme
|
| 511 |
+
Type: !Ref ALBType
|
| 512 |
+
LoadBalancerAttributes:
|
| 513 |
+
- Key: idle_timeout.timeout_seconds
|
| 514 |
+
Value: !Ref ALBAttributeIdleTimeOut
|
| 515 |
+
- Key: deletion_protection.enabled
|
| 516 |
+
Value: !Ref ALBAttributeDeletionProtection
|
| 517 |
+
- Key: routing.http2.enabled
|
| 518 |
+
Value: !Ref ALBAttributeRoutingHttp2
|
| 519 |
+
Subnets:
|
| 520 |
+
- !Ref PublicSubnetId1
|
| 521 |
+
- !Ref PublicSubnetId2
|
| 522 |
+
SecurityGroups:
|
| 523 |
+
- !Ref ALBExternalAccessSG
|
| 524 |
+
Tags:
|
| 525 |
+
- Key: Name
|
| 526 |
+
Value: !Sub ${AppName}-${Environment}-alb
|
| 527 |
+
- Key: Environment
|
| 528 |
+
Value: !Ref Environment
|
| 529 |
+
|
| 530 |
+
# ORIGIN ALB TARGET GROUP
|
| 531 |
+
OriginALBTG:
|
| 532 |
+
Type: AWS::ElasticLoadBalancingV2::TargetGroup
|
| 533 |
+
DependsOn: OriginALB
|
| 534 |
+
Properties:
|
| 535 |
+
Name: !Sub ${AppName}-${Environment}-alb-tg
|
| 536 |
+
HealthCheckProtocol: !Ref HealthCheckProtocol
|
| 537 |
+
HealthCheckPath: !Ref HealthCheckPath
|
| 538 |
+
HealthCheckPort: !Sub ${OriginALBTGPort}
|
| 539 |
+
HealthCheckIntervalSeconds: !Ref ALBTargetGroupHealthCheckIntervalSeconds
|
| 540 |
+
HealthCheckTimeoutSeconds: !Ref ALBTargetGroupHealthCheckTimeoutSeconds
|
| 541 |
+
HealthyThresholdCount: !Ref ALBTargetGroupHealthyThresholdCount
|
| 542 |
+
UnhealthyThresholdCount: !Ref ALBTargetGroupUnhealthyThresholdCount
|
| 543 |
+
TargetGroupAttributes:
|
| 544 |
+
- Key: deregistration_delay.timeout_seconds
|
| 545 |
+
Value: !Ref ALBTargetGroupAttributeDeregistration
|
| 546 |
+
TargetType: instance
|
| 547 |
+
Targets:
|
| 548 |
+
- Id: !Ref EC2Instance
|
| 549 |
+
Port: !Ref OriginALBTGPort
|
| 550 |
+
Port: !Ref OriginALBTGPort
|
| 551 |
+
Protocol: HTTP
|
| 552 |
+
VpcId: !Ref VpcId
|
| 553 |
+
Tags:
|
| 554 |
+
- Key: Name
|
| 555 |
+
Value: !Sub ${AppName}-${Environment}-alb-tg
|
| 556 |
+
- Key: Environment
|
| 557 |
+
Value: !Ref Environment
|
| 558 |
+
|
| 559 |
+
# ORIGIN ALB HTTPS LISTENER
|
| 560 |
+
OriginALBHttpsListener:
|
| 561 |
+
Type: AWS::ElasticLoadBalancingV2::Listener
|
| 562 |
+
DependsOn: OriginALBTG
|
| 563 |
+
Properties:
|
| 564 |
+
DefaultActions:
|
| 565 |
+
- TargetGroupArn: !Ref OriginALBTG
|
| 566 |
+
Type: forward
|
| 567 |
+
LoadBalancerArn: !Ref OriginALB
|
| 568 |
+
Port: 443
|
| 569 |
+
Protocol: HTTPS
|
| 570 |
+
Certificates:
|
| 571 |
+
- CertificateArn: !Sub arn:${AWS::Partition}:acm:${AWS::Region}:${AWS::AccountId}:certificate/${ACMCertificateIdentifier}
|
| 572 |
+
SslPolicy: ELBSecurityPolicy-FS-2018-06
|
| 573 |
+
|
| 574 |
+
# ORIGIN ALB HTTPS LISTENER RULE
|
| 575 |
+
OriginALBHttpsListenerRule:
|
| 576 |
+
Type: AWS::ElasticLoadBalancingV2::ListenerRule
|
| 577 |
+
DependsOn: OriginALBHttpsListener
|
| 578 |
+
Properties:
|
| 579 |
+
Actions:
|
| 580 |
+
- Type: forward
|
| 581 |
+
TargetGroupArn: !Ref OriginALBTG
|
| 582 |
+
Conditions:
|
| 583 |
+
- Field: path-pattern
|
| 584 |
+
Values:
|
| 585 |
+
- /*
|
| 586 |
+
ListenerArn: !Ref OriginALBHttpsListener
|
| 587 |
+
Priority: 1
|
| 588 |
+
|
| 589 |
+
# ALB EXTERNAL ACCESS SECURITY GROUP
|
| 590 |
+
ALBExternalAccessSG:
|
| 591 |
+
Type: AWS::EC2::SecurityGroup
|
| 592 |
+
Properties:
|
| 593 |
+
GroupDescription: Allow external access to ALB
|
| 594 |
+
VpcId: !Ref VpcId
|
| 595 |
+
Tags:
|
| 596 |
+
- Key: Name
|
| 597 |
+
Value: !Sub ${AppName}-${Environment}-alb-external-access-ingrees-SG
|
| 598 |
+
- Key: Environment
|
| 599 |
+
Value: !Ref Environment
|
| 600 |
+
|
| 601 |
+
# SECURITY GROUP INGRESS
|
| 602 |
+
HTTPSTcpIn:
|
| 603 |
+
Type: AWS::EC2::SecurityGroupIngress
|
| 604 |
+
Properties:
|
| 605 |
+
GroupId: !Ref ALBExternalAccessSG
|
| 606 |
+
ToPort: 443
|
| 607 |
+
IpProtocol: tcp
|
| 608 |
+
FromPort: 443
|
| 609 |
+
CidrIp: 0.0.0.0/0
|
| 610 |
+
|
| 611 |
+
HTTPTcpIn:
|
| 612 |
+
Type: AWS::EC2::SecurityGroupIngress
|
| 613 |
+
Properties:
|
| 614 |
+
GroupId: !Ref ALBExternalAccessSG
|
| 615 |
+
ToPort: 80
|
| 616 |
+
IpProtocol: tcp
|
| 617 |
+
FromPort: 80
|
| 618 |
+
CidrIp: 0.0.0.0/0
|
| 619 |
+
|
| 620 |
+
# SECURITY GROUP EGRESS
|
| 621 |
+
Tcp8080Out:
|
| 622 |
+
Type: AWS::EC2::SecurityGroupEgress
|
| 623 |
+
Properties:
|
| 624 |
+
GroupId: !Ref ALBExternalAccessSG
|
| 625 |
+
ToPort: 8080
|
| 626 |
+
IpProtocol: tcp
|
| 627 |
+
FromPort: 8080
|
| 628 |
+
DestinationSecurityGroupId: !Ref EC2InstanceSG
|
| 629 |
+
|
| 630 |
+
# CLOUDFRONT DISTRIBUTION
|
| 631 |
+
CloudFrontDistribution:
|
| 632 |
+
Type: AWS::CloudFront::Distribution
|
| 633 |
+
DependsOn:
|
| 634 |
+
- LoggingBucket
|
| 635 |
+
- LambdaEdgeFunction
|
| 636 |
+
Properties:
|
| 637 |
+
DistributionConfig:
|
| 638 |
+
Comment: Cloudfront Distribution pointing ALB Origin
|
| 639 |
+
Origins:
|
| 640 |
+
- DomainName: !GetAtt OriginALB.DNSName
|
| 641 |
+
Id: !Ref OriginALB
|
| 642 |
+
CustomOriginConfig:
|
| 643 |
+
HTTPPort: 80
|
| 644 |
+
HTTPSPort: 443
|
| 645 |
+
OriginProtocolPolicy: !Ref OriginProtocolPolicy
|
| 646 |
+
OriginKeepaliveTimeout: !Ref OriginKeepaliveTimeout
|
| 647 |
+
OriginReadTimeout: !Ref OriginReadTimeout
|
| 648 |
+
OriginSSLProtocols:
|
| 649 |
+
- TLSv1
|
| 650 |
+
- TLSv1.1
|
| 651 |
+
- TLSv1.2
|
| 652 |
+
- SSLv3
|
| 653 |
+
Enabled: true
|
| 654 |
+
HttpVersion: http2
|
| 655 |
+
Aliases:
|
| 656 |
+
- !Ref AlternateDomainNames
|
| 657 |
+
DefaultCacheBehavior:
|
| 658 |
+
AllowedMethods:
|
| 659 |
+
- GET
|
| 660 |
+
- HEAD
|
| 661 |
+
- DELETE
|
| 662 |
+
- OPTIONS
|
| 663 |
+
- PATCH
|
| 664 |
+
- POST
|
| 665 |
+
- PUT
|
| 666 |
+
Compress: !Ref Compress
|
| 667 |
+
DefaultTTL: !Ref DefaultTTL
|
| 668 |
+
MaxTTL: !Ref MaxTTL
|
| 669 |
+
MinTTL: !Ref MinTTL
|
| 670 |
+
SmoothStreaming: "false"
|
| 671 |
+
TargetOriginId: !Ref OriginALB
|
| 672 |
+
ForwardedValues:
|
| 673 |
+
QueryString: !Ref QueryString
|
| 674 |
+
Cookies:
|
| 675 |
+
Forward: !Ref ForwardCookies
|
| 676 |
+
ViewerProtocolPolicy: !Ref ViewerProtocolPolicy
|
| 677 |
+
LambdaFunctionAssociations:
|
| 678 |
+
- EventType: !Ref LambdaEventType
|
| 679 |
+
LambdaFunctionARN: !Ref LambdaEdgeVersion
|
| 680 |
+
PriceClass: !Ref PriceClass
|
| 681 |
+
ViewerCertificate:
|
| 682 |
+
AcmCertificateArn: !Sub arn:${AWS::Partition}:acm:${AWS::Region}:${AWS::AccountId}:certificate/${ACMCertificateIdentifier}
|
| 683 |
+
SslSupportMethod: !Ref SslSupportMethod
|
| 684 |
+
MinimumProtocolVersion: !Ref MinimumProtocolVersion
|
| 685 |
+
IPV6Enabled: !Ref IPV6Enabled
|
| 686 |
+
Logging:
|
| 687 |
+
Bucket: !Sub ${LoggingBucket}.s3.amazonaws.com
|
| 688 |
+
|
| 689 |
+
# LAMBDA@EDGE FUNCTION
|
| 690 |
+
LambdaEdgeFunction:
|
| 691 |
+
Type: AWS::Lambda::Function
|
| 692 |
+
Metadata:
|
| 693 |
+
guard:
|
| 694 |
+
SuppressedRules:
|
| 695 |
+
- LAMBDA_INSIDE_VPC
|
| 696 |
+
Properties:
|
| 697 |
+
Description: A custom Lambda@Edge function for serving custom headers from CloudFront Distribution
|
| 698 |
+
FunctionName: !Sub ${AppName}-lambda-edge-${Environment}
|
| 699 |
+
Handler: index.handler
|
| 700 |
+
Role: !GetAtt LambdaEdgeIAMRole.Arn
|
| 701 |
+
MemorySize: 128
|
| 702 |
+
Timeout: 5
|
| 703 |
+
Code:
|
| 704 |
+
ZipFile: |
|
| 705 |
+
'use strict';
|
| 706 |
+
|
| 707 |
+
exports.handler = (event, context, callback) => {
|
| 708 |
+
console.log('Adding additional headers to CloudFront response.');
|
| 709 |
+
|
| 710 |
+
const response = event.Records[0].cf.response;
|
| 711 |
+
response.headers['strict-transport-security'] = [{
|
| 712 |
+
key: 'Strict-Transport-Security',
|
| 713 |
+
value: 'max-age=86400; includeSubdomains; preload',
|
| 714 |
+
}];
|
| 715 |
+
response.headers['x-content-type-options'] = [{
|
| 716 |
+
key: 'X-Content-Type-Options',
|
| 717 |
+
value: 'nosniff',
|
| 718 |
+
}];
|
| 719 |
+
response.headers['x-frame-options'] = [{
|
| 720 |
+
key: 'X-Frame-Options',
|
| 721 |
+
value: "DENY"
|
| 722 |
+
}];
|
| 723 |
+
response.headers['content-security-policy'] = [{
|
| 724 |
+
key: 'Content-Security-Policy',
|
| 725 |
+
value: "default-src 'none'; img-src 'self'; script-src 'self'; style-src 'self'; object-src 'none'"
|
| 726 |
+
}];
|
| 727 |
+
response.headers['x-xss-protection'] = [{
|
| 728 |
+
key: 'X-XSS-Protection',
|
| 729 |
+
value: "1; mode=block"
|
| 730 |
+
}];
|
| 731 |
+
response.headers['referrer-policy'] = [{
|
| 732 |
+
key: 'Referrer-Policy',
|
| 733 |
+
value: "same-origin"
|
| 734 |
+
}];
|
| 735 |
+
callback(null, response);
|
| 736 |
+
};
|
| 737 |
+
Runtime: nodejs20.x
|
| 738 |
+
|
| 739 |
+
LambdaEdgeVersion:
|
| 740 |
+
Type: AWS::Lambda::Version
|
| 741 |
+
Properties:
|
| 742 |
+
FunctionName: !Ref LambdaEdgeFunction
|
| 743 |
+
|
| 744 |
+
Outputs:
|
| 745 |
+
AdministratorAccessIAMRole:
|
| 746 |
+
Description: Administrator Access IAM Role
|
| 747 |
+
Value: !Ref AdministratorAccessIAMRole
|
| 748 |
+
Export:
|
| 749 |
+
Name: !Sub ${AppName}-iam-${Environment}-administrator-access-role
|
| 750 |
+
|
| 751 |
+
LoggingBucket:
|
| 752 |
+
Description: Name of S3 Logging bucket
|
| 753 |
+
Value: !Ref LoggingBucket
|
| 754 |
+
Export:
|
| 755 |
+
Name: !Sub ${AppName}-logging-${Environment}-${AWS::AccountId}-${AWS::Region}
|
| 756 |
+
|
| 757 |
+
LoggingBucketKMSKey:
|
| 758 |
+
Description: Logging Bucket KMS Key
|
| 759 |
+
Value: !Ref LoggingBucketKMSKey
|
| 760 |
+
Export:
|
| 761 |
+
Name: !Sub ${AppName}-${Environment}-s3-logging-kms
|
| 762 |
+
|
| 763 |
+
OriginALB:
|
| 764 |
+
Description: The URL of the Origin ALB
|
| 765 |
+
Value: !GetAtt OriginALB.DNSName
|
| 766 |
+
Export:
|
| 767 |
+
Name: !Sub ${AppName}-${Environment}-origin-alb-dns
|
| 768 |
+
|
| 769 |
+
ALBExternalAccessSGID:
|
| 770 |
+
Description: ALB External Access Security Group ID
|
| 771 |
+
Value: !Ref ALBExternalAccessSG
|
| 772 |
+
Export:
|
| 773 |
+
Name: !Sub ${AppName}-${Environment}-alb-external-access-ingrees-sg
|
| 774 |
+
|
| 775 |
+
EC2InstanceSGID:
|
| 776 |
+
Description: EC2 Instance Security Group ID
|
| 777 |
+
Value: !Ref EC2InstanceSG
|
| 778 |
+
Export:
|
| 779 |
+
Name: !Sub ${AppName}-${Environment}-ec2-instance-sg
|
| 780 |
+
|
| 781 |
+
EC2InstanceDNS:
|
| 782 |
+
Description: EC2 Instance DNS Name
|
| 783 |
+
Value: !GetAtt EC2Instance.PrivateDnsName
|
| 784 |
+
Export:
|
| 785 |
+
Name: !Sub ${AppName}-${Environment}-ec2-instance-dns
|
| 786 |
+
|
| 787 |
+
EC2InstanceIP:
|
| 788 |
+
Description: EC2 Instance IP Address
|
| 789 |
+
Value: !GetAtt EC2Instance.PrivateIp
|
| 790 |
+
Export:
|
| 791 |
+
Name: !Sub ${AppName}-${Environment}-ec2-instance-ip-address
|
| 792 |
+
|
| 793 |
+
EC2InstanceID:
|
| 794 |
+
Description: EC2 Instance Instance ID
|
| 795 |
+
Value: !Ref EC2Instance
|
| 796 |
+
Export:
|
| 797 |
+
Name: !Sub ${AppName}-${Environment}-ec2-instance-id
|
| 798 |
+
|
| 799 |
+
CloudFrontEndpoint:
|
| 800 |
+
Description: Endpoint for Cloudfront Distribution
|
| 801 |
+
Value: !Ref CloudFrontDistribution
|
| 802 |
+
Export:
|
| 803 |
+
Name: !Sub ${AppName}-${Environment}-cloudfront-distribution
|
| 804 |
+
|
| 805 |
+
AlternateDomainNames:
|
| 806 |
+
Description: Alternate Domain Names (CNAME)
|
| 807 |
+
Value: !Ref AlternateDomainNames
|
| 808 |
+
|
| 809 |
+
LambdaEdgeFunction:
|
| 810 |
+
Description: The Name of the Lambda@Edge Function
|
| 811 |
+
Value: LambdaEdgeFunction
|
| 812 |
+
Export:
|
| 813 |
+
Name: !Sub ${AppName}-${Environment}-lambda-edge-function-3
|
| 814 |
+
|
| 815 |
+
LambdaEdgeFunctionARN:
|
| 816 |
+
Description: The ARN of the Lambda@Edge Function
|
| 817 |
+
Value: !GetAtt LambdaEdgeFunction.Arn
|
| 818 |
+
Export:
|
| 819 |
+
Name: !Sub ${AppName}-${Environment}-lambda-edge-function-arn-3
|
| 820 |
+
|
| 821 |
+
LambdaEdgeVersion:
|
| 822 |
+
Description: Lambda@Edge Version Function
|
| 823 |
+
Value: !GetAtt LambdaEdgeVersion.Version
|
human_reference_dataset/aws-cloudformation-templates/Solutions/CloudFrontCustomOriginLambda@Edge/LICENSE.txt
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT No Attribution
|
| 2 |
+
|
| 3 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
| 4 |
+
software and associated documentation files (the "Software"), to deal in the Software
|
| 5 |
+
without restriction, including without limitation the rights to use, copy, modify,
|
| 6 |
+
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
|
| 7 |
+
permit persons to whom the Software is furnished to do so.
|
| 8 |
+
|
| 9 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
| 10 |
+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
| 11 |
+
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
| 12 |
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
| 13 |
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
| 14 |
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
human_reference_dataset/aws-cloudformation-templates/Solutions/CloudFrontCustomOriginLambda@Edge/README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Create an AWS CloudFront Distribution with Custom Origin (ALB) and Lambda@Edge Example
|
| 2 |
+
|
| 3 |
+
## Issue
|
| 4 |
+
AWS CloudFront distribution with custom origin with AWS Lambda@Edge provisioning requires a lot of manual steps.
|
| 5 |
+
|
| 6 |
+
## Short Description
|
| 7 |
+
CI/CD optimized AWS CloudFormation Sample Template for AWS CloudFront Distribution with Custom Origin with an example of using the AWS Application Load Balancer (ALB) and a basic Amazon EC2 Instance. AWS CloudFront Distribution is associated with Lambda@Edge for Security Headers inspection. In addition, AWS CloudFormation Template will provision an Examples of necessary IAM, S3, KMS and Security Groups resources.
|
| 8 |
+
|
| 9 |
+
## Resolution
|
| 10 |
+
Using this AWS CloudFormation Template Example enables CI/CD optimized and automated deployment of all necessary components while provides the flexibility with variety of defined variables.
|
| 11 |
+
|
| 12 |
+
## Instructions
|
| 13 |
+
|
| 14 |
+
The following steps provide a brief overview of this process:
|
| 15 |
+
* Upload certificate to AWS Amazon Certificate Manager (ACM) in N.Virginia Region.
|
| 16 |
+
* Review provided Parameters and set values that match your use case.
|
| 17 |
+
* While creating the CloudFormation stack, please make sure to select the following networking parameter values from the dropdown in Parameters section:
|
| 18 |
+
|
| 19 |
+
- **VpcId:** Select a VPC ID
|
| 20 |
+
- **PublicSubnetId1:** Select the first public subnet from the above VPC
|
| 21 |
+
- **PublicSubnetId2:** Select the second public subnet from the above VPC
|
| 22 |
+
- **KeyPairName:** Select an EC2 Key Pair
|
| 23 |
+
|
| 24 |
+
* Expand solution with additional resources as AutoScaling, etc. that match your use case
|
| 25 |
+
|
| 26 |
+
## Builders
|
| 27 |
+
|
| 28 |
+
# Nikola Bravo: @NikolaBravo
|
| 29 |
+
# Rohit Rangnekar: @rrangnekar
|
| 30 |
+
# Anubha Singhal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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"AWSTemplateFormatVersion": "2010-09-09",
|
| 3 |
+
"Description": "Deploys the prequisites for creating required code pipelines this includes \n",
|
| 4 |
+
"Parameters": {
|
| 5 |
+
"DockerImage": {
|
| 6 |
+
"Description": "Docker image to use for the build phase",
|
| 7 |
+
"Type": "String",
|
| 8 |
+
"Default": "aws/codebuild/standard:7.0"
|
| 9 |
+
}
|
| 10 |
+
},
|
| 11 |
+
"Resources": {
|
| 12 |
+
"CodeCommitRepo": {
|
| 13 |
+
"Type": "AWS::CodeCommit::Repository",
|
| 14 |
+
"Properties": {
|
| 15 |
+
"RepositoryName": {
|
| 16 |
+
"Fn::Sub": "${AWS::StackName}-repo"
|
| 17 |
+
},
|
| 18 |
+
"RepositoryDescription": {
|
| 19 |
+
"Fn::Sub": "This is a repository for the ${AWS::StackName} project."
|
| 20 |
+
}
|
| 21 |
+
}
|
| 22 |
+
},
|
| 23 |
+
"PipelineS3Bucket": {
|
| 24 |
+
"Type": "AWS::S3::Bucket",
|
| 25 |
+
"Metadata": {
|
| 26 |
+
"guard": {
|
| 27 |
+
"SuppressedRules": [
|
| 28 |
+
"S3_BUCKET_DEFAULT_LOCK_ENABLED",
|
| 29 |
+
"S3_BUCKET_REPLICATION_ENABLED",
|
| 30 |
+
"S3_BUCKET_VERSIONING_ENABLED",
|
| 31 |
+
"S3_BUCKET_LOGGING_ENABLED"
|
| 32 |
+
]
|
| 33 |
+
}
|
| 34 |
+
},
|
| 35 |
+
"Properties": {
|
| 36 |
+
"BucketName": {
|
| 37 |
+
"Fn::Sub": "${AWS::StackName}-bucket"
|
| 38 |
+
},
|
| 39 |
+
"BucketEncryption": {
|
| 40 |
+
"ServerSideEncryptionConfiguration": [
|
| 41 |
+
{
|
| 42 |
+
"ServerSideEncryptionByDefault": {
|
| 43 |
+
"SSEAlgorithm": "AES256"
|
| 44 |
+
}
|
| 45 |
+
}
|
| 46 |
+
]
|
| 47 |
+
},
|
| 48 |
+
"PublicAccessBlockConfiguration": {
|
| 49 |
+
"BlockPublicAcls": true,
|
| 50 |
+
"BlockPublicPolicy": true,
|
| 51 |
+
"IgnorePublicAcls": true,
|
| 52 |
+
"RestrictPublicBuckets": true
|
| 53 |
+
}
|
| 54 |
+
}
|
| 55 |
+
},
|
| 56 |
+
"CodeBuildRole": {
|
| 57 |
+
"Type": "AWS::IAM::Role",
|
| 58 |
+
"Properties": {
|
| 59 |
+
"AssumeRolePolicyDocument": {
|
| 60 |
+
"Statement": [
|
| 61 |
+
{
|
| 62 |
+
"Effect": "Allow",
|
| 63 |
+
"Action": "sts:AssumeRole",
|
| 64 |
+
"Principal": {
|
| 65 |
+
"Service": "codebuild.amazonaws.com"
|
| 66 |
+
}
|
| 67 |
+
}
|
| 68 |
+
],
|
| 69 |
+
"Version": "2012-10-17"
|
| 70 |
+
},
|
| 71 |
+
"Policies": [
|
| 72 |
+
{
|
| 73 |
+
"PolicyName": "CanLog",
|
| 74 |
+
"PolicyDocument": {
|
| 75 |
+
"Version": "2012-10-17",
|
| 76 |
+
"Statement": [
|
| 77 |
+
{
|
| 78 |
+
"Effect": "Allow",
|
| 79 |
+
"Action": [
|
| 80 |
+
"logs:CreateLogStream",
|
| 81 |
+
"logs:CreateLogGroup",
|
| 82 |
+
"logs:PutLogEvents"
|
| 83 |
+
],
|
| 84 |
+
"Resource": [
|
| 85 |
+
{
|
| 86 |
+
"Fn::Sub": "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/codebuild/${AWS::StackName}*:log-stream:*"
|
| 87 |
+
}
|
| 88 |
+
]
|
| 89 |
+
},
|
| 90 |
+
{
|
| 91 |
+
"Effect": "Allow",
|
| 92 |
+
"Action": [
|
| 93 |
+
"s3:GetObject",
|
| 94 |
+
"s3:PutObject"
|
| 95 |
+
],
|
| 96 |
+
"Resource": [
|
| 97 |
+
{
|
| 98 |
+
"Fn::GetAtt": [
|
| 99 |
+
"PipelineS3Bucket",
|
| 100 |
+
"Arn"
|
| 101 |
+
]
|
| 102 |
+
},
|
| 103 |
+
{
|
| 104 |
+
"Fn::Sub": "${PipelineS3Bucket.Arn}/*"
|
| 105 |
+
}
|
| 106 |
+
]
|
| 107 |
+
}
|
| 108 |
+
]
|
| 109 |
+
}
|
| 110 |
+
},
|
| 111 |
+
{
|
| 112 |
+
"PolicyName": "CanAccessS3",
|
| 113 |
+
"PolicyDocument": {
|
| 114 |
+
"Version": "2012-10-17",
|
| 115 |
+
"Statement": [
|
| 116 |
+
{
|
| 117 |
+
"Effect": "Allow",
|
| 118 |
+
"Action": [
|
| 119 |
+
"s3:GetObject"
|
| 120 |
+
],
|
| 121 |
+
"Resource": [
|
| 122 |
+
{
|
| 123 |
+
"Fn::GetAtt": [
|
| 124 |
+
"PipelineS3Bucket",
|
| 125 |
+
"Arn"
|
| 126 |
+
]
|
| 127 |
+
}
|
| 128 |
+
]
|
| 129 |
+
}
|
| 130 |
+
]
|
| 131 |
+
}
|
| 132 |
+
},
|
| 133 |
+
{
|
| 134 |
+
"PolicyName": "CanCreateReports",
|
| 135 |
+
"PolicyDocument": {
|
| 136 |
+
"Version": "2012-10-17",
|
| 137 |
+
"Statement": [
|
| 138 |
+
{
|
| 139 |
+
"Effect": "Allow",
|
| 140 |
+
"Action": [
|
| 141 |
+
"codebuild:*"
|
| 142 |
+
],
|
| 143 |
+
"Resource": [
|
| 144 |
+
{
|
| 145 |
+
"Fn::Sub": "arn:${AWS::Partition}:codebuild:${AWS::Region}:${AWS::AccountId}:report-group/${AWS::StackName}*"
|
| 146 |
+
}
|
| 147 |
+
]
|
| 148 |
+
}
|
| 149 |
+
]
|
| 150 |
+
}
|
| 151 |
+
}
|
| 152 |
+
]
|
| 153 |
+
}
|
| 154 |
+
},
|
| 155 |
+
"AppBuild": {
|
| 156 |
+
"Type": "AWS::CodeBuild::Project",
|
| 157 |
+
"Properties": {
|
| 158 |
+
"Name": {
|
| 159 |
+
"Fn::Sub": "${AWS::StackName}-app-build"
|
| 160 |
+
},
|
| 161 |
+
"Artifacts": {
|
| 162 |
+
"Type": "CODEPIPELINE",
|
| 163 |
+
"EncryptionDisabled": true
|
| 164 |
+
},
|
| 165 |
+
"Environment": {
|
| 166 |
+
"ComputeType": "BUILD_GENERAL1_SMALL",
|
| 167 |
+
"EnvironmentVariables": [
|
| 168 |
+
{
|
| 169 |
+
"Name": "SAMPLEENVVAR",
|
| 170 |
+
"Type": "PLAINTEXT",
|
| 171 |
+
"Value": "test"
|
| 172 |
+
}
|
| 173 |
+
],
|
| 174 |
+
"Image": {
|
| 175 |
+
"Ref": "DockerImage"
|
| 176 |
+
},
|
| 177 |
+
"Type": "LINUX_CONTAINER"
|
| 178 |
+
},
|
| 179 |
+
"ServiceRole": {
|
| 180 |
+
"Ref": "CodeBuildRole"
|
| 181 |
+
},
|
| 182 |
+
"Source": {
|
| 183 |
+
"Type": "CODEPIPELINE",
|
| 184 |
+
"BuildSpec": "codebuild-app-build.yml"
|
| 185 |
+
}
|
| 186 |
+
}
|
| 187 |
+
},
|
| 188 |
+
"AppDeploy": {
|
| 189 |
+
"Type": "AWS::CodeBuild::Project",
|
| 190 |
+
"Properties": {
|
| 191 |
+
"Name": {
|
| 192 |
+
"Fn::Sub": "${AWS::StackName}-app-deploy"
|
| 193 |
+
},
|
| 194 |
+
"Artifacts": {
|
| 195 |
+
"Type": "CODEPIPELINE",
|
| 196 |
+
"EncryptionDisabled": true
|
| 197 |
+
},
|
| 198 |
+
"Environment": {
|
| 199 |
+
"ComputeType": "BUILD_GENERAL1_SMALL",
|
| 200 |
+
"EnvironmentVariables": [
|
| 201 |
+
{
|
| 202 |
+
"Name": "SAMPLEENVVAR",
|
| 203 |
+
"Type": "PLAINTEXT",
|
| 204 |
+
"Value": "test"
|
| 205 |
+
}
|
| 206 |
+
],
|
| 207 |
+
"Image": {
|
| 208 |
+
"Ref": "DockerImage"
|
| 209 |
+
},
|
| 210 |
+
"Type": "LINUX_CONTAINER"
|
| 211 |
+
},
|
| 212 |
+
"ServiceRole": {
|
| 213 |
+
"Ref": "CodeBuildRole"
|
| 214 |
+
},
|
| 215 |
+
"Source": {
|
| 216 |
+
"Type": "CODEPIPELINE",
|
| 217 |
+
"BuildSpec": "codebuild-app-deploy.yml"
|
| 218 |
+
}
|
| 219 |
+
}
|
| 220 |
+
}
|
| 221 |
+
},
|
| 222 |
+
"Outputs": {
|
| 223 |
+
"CodeCommitName": {
|
| 224 |
+
"Description": "The code commit repository name",
|
| 225 |
+
"Value": {
|
| 226 |
+
"Fn::GetAtt": [
|
| 227 |
+
"CodeCommitRepo",
|
| 228 |
+
"Name"
|
| 229 |
+
]
|
| 230 |
+
},
|
| 231 |
+
"Export": {
|
| 232 |
+
"Name": {
|
| 233 |
+
"Fn::Sub": "${AWS::StackName}-CodeCommitName"
|
| 234 |
+
}
|
| 235 |
+
}
|
| 236 |
+
},
|
| 237 |
+
"CodeCommitArn": {
|
| 238 |
+
"Description": "The code commit repository arn",
|
| 239 |
+
"Value": {
|
| 240 |
+
"Fn::GetAtt": [
|
| 241 |
+
"CodeCommitRepo",
|
| 242 |
+
"Arn"
|
| 243 |
+
]
|
| 244 |
+
},
|
| 245 |
+
"Export": {
|
| 246 |
+
"Name": {
|
| 247 |
+
"Fn::Sub": "${AWS::StackName}-CodeCommitArn"
|
| 248 |
+
}
|
| 249 |
+
}
|
| 250 |
+
},
|
| 251 |
+
"PipelineS3Bucket": {
|
| 252 |
+
"Description": "The s3 bucket used by the deployment codepipelines",
|
| 253 |
+
"Value": {
|
| 254 |
+
"Ref": "PipelineS3Bucket"
|
| 255 |
+
},
|
| 256 |
+
"Export": {
|
| 257 |
+
"Name": {
|
| 258 |
+
"Fn::Sub": "${AWS::StackName}-PipelineS3Bucket"
|
| 259 |
+
}
|
| 260 |
+
}
|
| 261 |
+
},
|
| 262 |
+
"PipelineS3BucketArn": {
|
| 263 |
+
"Description": "The s3 bucket used by the deployment codepipelines",
|
| 264 |
+
"Value": {
|
| 265 |
+
"Fn::GetAtt": [
|
| 266 |
+
"PipelineS3Bucket",
|
| 267 |
+
"Arn"
|
| 268 |
+
]
|
| 269 |
+
},
|
| 270 |
+
"Export": {
|
| 271 |
+
"Name": {
|
| 272 |
+
"Fn::Sub": "${AWS::StackName}-PipelineS3BucketArn"
|
| 273 |
+
}
|
| 274 |
+
}
|
| 275 |
+
},
|
| 276 |
+
"CodeBuildRole": {
|
| 277 |
+
"Description": "IAM Role ARN associated with CodeBuild projects",
|
| 278 |
+
"Value": {
|
| 279 |
+
"Ref": "CodeBuildRole"
|
| 280 |
+
},
|
| 281 |
+
"Export": {
|
| 282 |
+
"Name": {
|
| 283 |
+
"Fn::Sub": "${AWS::StackName}-CodeBuildRole"
|
| 284 |
+
}
|
| 285 |
+
}
|
| 286 |
+
},
|
| 287 |
+
"CodeBuildRoleArn": {
|
| 288 |
+
"Description": "IAM Role ARN associated with CodeBuild projects",
|
| 289 |
+
"Value": {
|
| 290 |
+
"Fn::GetAtt": [
|
| 291 |
+
"CodeBuildRole",
|
| 292 |
+
"Arn"
|
| 293 |
+
]
|
| 294 |
+
},
|
| 295 |
+
"Export": {
|
| 296 |
+
"Name": {
|
| 297 |
+
"Fn::Sub": "${AWS::StackName}-CodeBuildRoleArn"
|
| 298 |
+
}
|
| 299 |
+
}
|
| 300 |
+
},
|
| 301 |
+
"AppDeploy": {
|
| 302 |
+
"Value": {
|
| 303 |
+
"Ref": "AppDeploy"
|
| 304 |
+
},
|
| 305 |
+
"Export": {
|
| 306 |
+
"Name": {
|
| 307 |
+
"Fn::Sub": "${AWS::StackName}-AppDeploy"
|
| 308 |
+
}
|
| 309 |
+
}
|
| 310 |
+
},
|
| 311 |
+
"AppDeploydArn": {
|
| 312 |
+
"Value": {
|
| 313 |
+
"Fn::GetAtt": [
|
| 314 |
+
"AppDeploy",
|
| 315 |
+
"Arn"
|
| 316 |
+
]
|
| 317 |
+
},
|
| 318 |
+
"Export": {
|
| 319 |
+
"Name": {
|
| 320 |
+
"Fn::Sub": "${AWS::StackName}-AppDeployArn"
|
| 321 |
+
}
|
| 322 |
+
}
|
| 323 |
+
},
|
| 324 |
+
"AppBuild": {
|
| 325 |
+
"Value": {
|
| 326 |
+
"Ref": "AppBuild"
|
| 327 |
+
},
|
| 328 |
+
"Export": {
|
| 329 |
+
"Name": {
|
| 330 |
+
"Fn::Sub": "${AWS::StackName}-AppBuild"
|
| 331 |
+
}
|
| 332 |
+
}
|
| 333 |
+
},
|
| 334 |
+
"AppBuildArn": {
|
| 335 |
+
"Value": {
|
| 336 |
+
"Fn::GetAtt": [
|
| 337 |
+
"AppBuild",
|
| 338 |
+
"Arn"
|
| 339 |
+
]
|
| 340 |
+
},
|
| 341 |
+
"Export": {
|
| 342 |
+
"Name": {
|
| 343 |
+
"Fn::Sub": "${AWS::StackName}-AppBuildArn"
|
| 344 |
+
}
|
| 345 |
+
}
|
| 346 |
+
}
|
| 347 |
+
}
|
| 348 |
+
}
|