├── .gitignore ├── .gitmodules ├── .metadata ├── .nojekyll ├── .taskcat.yml ├── CODEOWNERS ├── LICENSE.txt ├── NOTICE.txt ├── README.md ├── scripts ├── destroy.sh ├── install.sh └── utilities.sh └── templates ├── ibm-mq-create-eks.template.yaml ├── ibm-mq-ec2-bootnode.template.yaml ├── ibm-mq-eks-workload.template.yaml ├── ibm-mq-iam-role.template.yaml └── ibm-mq-main.template.yaml /.gitignore: -------------------------------------------------------------------------------- 1 | ct/custom-control-tower-configuration.zip 2 | .idea 3 | .DS_Store 4 | .taskcat 5 | taskcat_outputs 6 | 7 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "submodules/quickstart-aws-vpc"] 2 | path = submodules/quickstart-aws-vpc 3 | url = https://github.com/aws-quickstart/quickstart-aws-vpc.git 4 | branch = main 5 | -------------------------------------------------------------------------------- /.metadata: -------------------------------------------------------------------------------- 1 | language_type: cloudformation 2 | -------------------------------------------------------------------------------- /.nojekyll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-quickstart/quickstart-ibm-mq/cebfe142d3c2027854c8bc60ebebf890ddc1f5be/.nojekyll -------------------------------------------------------------------------------- /.taskcat.yml: -------------------------------------------------------------------------------- 1 | general: 2 | s3_regional_buckets: true 3 | project: 4 | name: quickstart-ibm-mq 5 | package_lambda: false 6 | shorten_stack_name: true 7 | regions: 8 | - us-east-1 9 | - us-east-2 10 | - us-west-1 11 | - us-west-2 12 | - ca-central-1 13 | - eu-central-1 14 | - eu-west-1 15 | - eu-west-2 16 | - eu-west-3 17 | - ap-southeast-1 18 | - ap-southeast-2 19 | - ap-northeast-1 20 | - ap-northeast-2 21 | - ap-south-1 22 | s3_bucket: '' 23 | parameters: 24 | EKSClusterName: mq-cluster-$[taskcat_random-string] 25 | QSS3BucketName: $[taskcat_autobucket] 26 | QSS3BucketRegion: $[taskcat_current_region] 27 | QSS3KeyPrefix: $[taskcat_project_name]/ 28 | AvailabilityZones: $[taskcat_genaz_3] 29 | MQAppPassword: $[taskcat_genpass_10] 30 | MQAdminPassword: $[taskcat_genpass_10] 31 | tests: 32 | mq-eks-private: 33 | template: ./templates/ibm-mq-main.template.yaml 34 | parameters: 35 | InternalLoadBalancer: "true" 36 | regions: 37 | - eu-west-1 38 | - eu-west-2 39 | mq-eks-public: 40 | template: ./templates/ibm-mq-main.template.yaml 41 | parameters: 42 | InternalLoadBalancer: "false" 43 | regions: 44 | - eu-west-3 -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @aws-quickstart/aws_quickstart_team 2 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /NOTICE.txt: -------------------------------------------------------------------------------- 1 | Copyright 2016-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy of the License is located at 4 | 5 | http://aws.amazon.com/apache2.0/ 6 | 7 | or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # quickstart-ibm-mq 2 | ## Deprecation Notice 3 | 4 | :x: This repository is subject to deprecation in Q4 2024. For more details, [please review this announcement](https://github.com/aws-ia/.announcements/issues/1). 5 | 6 | ## This repository has been deprecated in favor of https://github.com/aws-ia/cfn-ps-ibm-mq. 7 | ***We will archive this repository and keep it publicly available until May 1, 2024.*** 8 | -------------------------------------------------------------------------------- /scripts/destroy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # ********************************************************************* 3 | # * IBM Confidential 4 | # * OCO Source Materials 5 | # * 6 | # * Copyright IBM Corp. 2022 7 | # * 8 | # * The source code for this program is not published or otherwise 9 | # * divested of its trade secrets, irrespective of what has been 10 | # * deposited with the U.S. Copyright Office. 11 | # ********************************************************************* 12 | set -o pipefail 13 | CUR_DIR="$(cd $(dirname $0) && pwd)" 14 | source $CUR_DIR/ibm-mq-parameters.properties 15 | 16 | export AWS_DEFAULT_REGION 17 | 18 | if eksctl get cluster "${EKS_CLUSTER_NAME}"; then 19 | echo "Deleting cluster ${EKS_CLUSTER_NAME}..." 20 | eksctl delete cluster --wait "${EKS_CLUSTER_NAME}" 21 | else 22 | echo "Cluster ${EKS_CLUSTER_NAME} does not exist." 23 | fi 24 | -------------------------------------------------------------------------------- /scripts/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -o pipefail 3 | CUR_DIR="$(cd $(dirname $0) && pwd)" 4 | source $CUR_DIR/ibm-mq-parameters.properties 5 | source $CUR_DIR/utilities.sh 6 | 7 | sudo yum install -y -q jq git 8 | 9 | create_namespace() { 10 | namespace=$1 11 | 12 | if ! kubectl get namespace "${namespace}" >/dev/null; then 13 | echo "Creating the namespace '${namespace}'..." 14 | kubectl create namespace "${namespace}" 15 | else 16 | echo "The namespace ${namespace} already exists." 17 | fi 18 | } 19 | 20 | # Update aws cli: https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html 21 | # On the EC2 instance, out of the box, aws command is installed at /usr/bin/aws and is older version 22 | # aws --version => aws-cli/1.18.147 Python/2.7.18 Linux/4.14.231-173.361.amzn2.x86_64 botocore/1.18.6 23 | # By default, (aws cli install) files are all installed to /usr/local/aws-cli, and a symbolic link is created in /usr/local/bin. 24 | if ! aws --version | grep --color=never 'aws-cli/2'; then 25 | echo "Version 1 of the AWS CLI is installed. Updating to version 2." 26 | sudo rm -rf `which aws` 27 | curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscli_new.zip" 28 | unzip -u -q awscli_new.zip 29 | sudo ./aws/install 30 | export PATH=/usr/local/bin:${PATH} 31 | echo "Updated aws cli version:" `aws --version` 32 | fi 33 | 34 | # Update the .kube/config file to access the cluster with kubectl 35 | echo "aws eks update-kubeconfig --name ${EKS_CLUSTER_NAME}" 36 | aws eks update-kubeconfig --name ${EKS_CLUSTER_NAME} 37 | 38 | # Install kubectl 39 | curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" 40 | sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl 41 | echo "kubectl version: " `kubectl version` 42 | 43 | # Install helm 44 | curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 45 | chmod 700 get_helm.sh 46 | ./get_helm.sh 47 | 48 | # EKS setup - OIDC provider, Service Account, EBS CSI driver 49 | eksctl utils associate-iam-oidc-provider --region=$AWS_DEFAULT_REGION --cluster=$EKS_CLUSTER_NAME --approve 50 | eksctl create iamserviceaccount --name ebs-csi-controller-sa --namespace kube-system --cluster $EKS_CLUSTER_NAME --region $AWS_DEFAULT_REGION --attach-policy-arn arn:aws:iam::aws:policy/service-role/AmazonEBSCSIDriverPolicy --approve --role-only --role-name AmazonEKS_EBS_CSI_DriverRole_${EKS_CLUSTER_NAME: -10}-$AWS_DEFAULT_REGION 51 | AWS_ACCOUNT_ID=$(aws sts get-caller-identity | jq -r '.Account') 52 | eksctl create addon --name aws-ebs-csi-driver --cluster $EKS_CLUSTER_NAME --region $AWS_DEFAULT_REGION --service-account-role-arn arn:aws:iam::$AWS_ACCOUNT_ID:role/AmazonEKS_EBS_CSI_DriverRole_${EKS_CLUSTER_NAME: -10}-$AWS_DEFAULT_REGION --force 53 | 54 | # Wait for addon to become active 55 | check_addon_active $EKS_CLUSTER_NAME $AWS_DEFAULT_REGION 56 | 57 | # Create the APPLICATION_NAMESPACE if it doesn't exist 58 | echo "Creating namespaces..." 59 | if [[ -n "${APPLICATION_NAMESPACE}" && "${APPLICATION_NAMESPACE,,}" != "default" ]]; then 60 | create_namespace "${APPLICATION_NAMESPACE}" 61 | fi 62 | 63 | # Install MQ helm chart 64 | echo "Installing IBM MQ helm chart..." 65 | cd $CUR_DIR/.. 66 | git clone --depth 1 --branch main https://github.com/ibm-messaging/mq-helm.git 67 | cd mq-helm/samples/AWSEKSPartnerSolution/deploy/ 68 | ./install.sh $APPLICATION_NAMESPACE $ADMIN_PASSWORD $APP_PASSWORD $INTERNAL_LOAD_BALANCER 69 | 70 | #Wait 2 minutes for POD to be in a running state 71 | sleep 120 72 | wait_for services secureapphelm-ibm-mq-loadbalancer $APPLICATION_NAMESPACE 73 | export CONSOLE_PORT=9443 74 | export CONSOLE_IP=$(kubectl get services secureapphelm-ibm-mq-loadbalancer -n $APPLICATION_NAMESPACE -o jsonpath="{..hostname}") 75 | export MQ_URL=$(echo https://$CONSOLE_IP:$CONSOLE_PORT/ibmmq/console) 76 | aws ssm put-parameter --name $MQURL_SSM_PARAMETER --value $MQ_URL --type String --overwrite 77 | 78 | #Deleting passwords from text file: 79 | sed -i '/_PASSWORD/d' $CUR_DIR/ibm-mq-parameters.properties 80 | 81 | sudo shutdown +2 "IBM MQ installation is complete. \ 82 | #The system will now shut down in 2 minutes. If you are currently \ 83 | #using this system, run 'sudo shutdown -c' to stop the shutdown." 84 | -------------------------------------------------------------------------------- /scripts/utilities.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -o pipefail 3 | 4 | DEPLOY="Passed" 5 | 6 | separator() { 7 | echo "--------------------------------------------------------------------------------------" 8 | } 9 | 10 | check_addon_active() { 11 | cluster_name=$1 12 | region_name=$2 13 | addon_name=aws-ebs-csi-driver 14 | status_out=$(eksctl get addon --name aws-ebs-csi-driver --cluster $EKS_CLUSTER_NAME --region $AWS_DEFAULT_REGION --output json | jq -r '.[]|.Status') 15 | 16 | while [ $status_out != "ACTIVE" ]; do 17 | if [ $count -eq $MAX_RETRIES ]; then 18 | echo "Timeout and exit due to maximum retires reached." 19 | return 1 20 | fi 21 | 22 | count=$((count+1)) 23 | sleep 5s 24 | status_out=$(eksctl get addon --name aws-ebs-csi-driver --cluster $EKS_CLUSTER_NAME --region $AWS_DEFAULT_REGION --output json | jq -r '.[]|.Status') 25 | done 26 | 27 | echo "The ${cluster_name} ${addon_name} is $status_out." 28 | } 29 | 30 | wait_for() { 31 | type=$1 32 | name=$2 33 | namespace=${3:-default} 34 | 35 | MAX_RETRIES=199 36 | count=0 37 | 38 | echo "Waiting for ${type} ${name} to be ready..." 39 | kubectl get ${type} ${name} -n ${namespace} 40 | 41 | while [ $? -ne 0 ]; do 42 | if [ $count -eq $MAX_RETRIES ]; then 43 | echo "Timeout and exit due to maximum retires reached." 44 | return 1 45 | fi 46 | 47 | count=$((count+1)) 48 | 49 | echo "Unable to get ${type} ${name}: retry ${count} of ${MAX_RETRIES}." 50 | sleep 5s 51 | kubectl get ${type} ${name} -n ${namespace} 52 | done 53 | 54 | echo "The ${type} ${name} is ready." 55 | 56 | if [[ "${type}" == *"deploy"* ]]; then 57 | echo "Waiting for deployment ${name} pods to be ready..." 58 | count=0 59 | podStatus="$(kubectl get deploy ${name} -n ${namespace} -o=jsonpath='{.status.readyReplicas}{"/"}{.status.replicas}')" 60 | readyPods="$(echo $podStatus | cut -d / -f 1)" 61 | desiredPods="$(echo $podStatus | cut -d / -f 2)" 62 | 63 | while [[ "${readyPods}" -ne "${desiredPods}" ]]; do 64 | if [ $count -eq $MAX_RETRIES ]; then 65 | echo "Timeout and exit due to maximum retires reached." 66 | return 1 67 | fi 68 | 69 | count=$((count+1)) 70 | 71 | echo "${readyPods:-0}/${desiredPods} ready for deployment ${name}. Retry ${count} of ${MAX_RETRIES}." 72 | sleep 5s 73 | podStatus="$(kubectl get deploy ${name} -n ${namespace} -o=jsonpath='{.status.readyReplicas}{"/"}{.status.replicas}')" 74 | readyPods="$(echo $podStatus | cut -d / -f 1)" 75 | desiredPods="$(echo $podStatus | cut -d / -f 2)" 76 | done 77 | 78 | echo "All pods ready for deployment ${name}." 79 | fi 80 | 81 | if [[ "${type}" == "service" || "${type}" == "svc" ]]; then 82 | echo "Waiting for service ${name} ingress to be ready..." 83 | curl -k -silent https://$svcEndpoint > svcEndpoint.log 84 | curl_return=$? 85 | count=0 86 | svcEndpoint="$(kubectl get service ${name} -n ${namespace} -o=jsonpath='{.status.loadBalancer.ingress[*].hostname}')" 87 | 88 | while [[ $? != 0 || -z "${svcEndpoint}" || $curl_return != 0 ]]; do 89 | if [ $count -eq $MAX_RETRIES ]; then 90 | echo "Timeout and exit due to maximum retires reached." 91 | return 1 92 | fi 93 | 94 | count=$((count+1)) 95 | 96 | echo "Failed to get ingress endpoint for service ${name}. Retry ${count} of ${MAX_RETRIES}." 97 | sleep 5s 98 | curl -k -silent https://$svcEndpoint > svcEndpoint.log 99 | curl_return=$? 100 | svcEndpoint="$(kubectl get service ${name} -n ${namespace} -o=jsonpath='{.status.loadBalancer.ingress[*].hostname}')" 101 | done 102 | 103 | echo "All pods ready for deployment ${name}." 104 | fi 105 | } 106 | -------------------------------------------------------------------------------- /templates/ibm-mq-create-eks.template.yaml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion: 2010-09-09 2 | Description: This template creates an EKS cluster using eksctl from an EC2 instance. (qs-1tss294hs) 3 | Metadata: 4 | AWS::CloudFormation::Interface: 5 | ParameterGroups: 6 | - Label: 7 | default: EKS configuration 8 | Parameters: 9 | - BootNodeInstanceId 10 | - EKSClusterName 11 | ParameterLabels: 12 | EKSClusterName: 13 | default: EKS Cluster Name 14 | BootNodeInstanceId: 15 | default: Boot node instance ID 16 | Parameters: 17 | BootNodeInstanceId: 18 | Type: AWS::EC2::Instance::Id 19 | Description: Boot Node Instance Id 20 | EKSClusterName: 21 | Type: String 22 | Description: Name for the new cluster*. 23 | Resources: 24 | SpecificInstanceIdAssociation: 25 | Type: AWS::SSM::Association 26 | Properties: 27 | Name: AWS-RunShellScript 28 | Targets: 29 | - Key: InstanceIds 30 | Values: 31 | - !Ref BootNodeInstanceId 32 | Parameters: 33 | commands: 34 | - | 35 | #!/bin/bash 36 | curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp 37 | sudo mv /tmp/eksctl /usr/local/bin 38 | - | 39 | #!/bin/bash 40 | i=0 41 | while [ ! -f /opt/ibm/cluster.yaml ]; do 42 | echo "/opt/ibm/cluster.yaml isn't available yet, waiting" 43 | sleep 5 44 | i=$[$i+1] 45 | if [ $i -ge 18 ]; then 46 | echo "Timed out waiting 90 seconds for /opt/ibm/cluster.yaml to be available" 47 | break; 48 | fi 49 | echo "/opt/ibm/cluster.yaml ready:" 50 | cat /opt/ibm/cluster.yaml 51 | done 52 | - | 53 | #!/bin/bash 54 | cd /opt/ibm 55 | eksctl create cluster -f /opt/ibm/cluster.yaml > /opt/ibm/eksctl.log 56 | workingDirectory: 57 | - /tmp 58 | WaitForSuccessTimeoutSeconds: 1200 59 | 60 | LambdaExecutionRole: 61 | Type: AWS::IAM::Role 62 | Properties: 63 | AssumeRolePolicyDocument: 64 | Version: '2012-10-17' 65 | Statement: 66 | - Effect: Allow 67 | Principal: 68 | Service: lambda.amazonaws.com 69 | Action: sts:AssumeRole 70 | ManagedPolicyArns: 71 | - !Sub arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole 72 | - !Sub arn:${AWS::Partition}:iam::aws:policy/AmazonSSMManagedInstanceCore 73 | - !Sub arn:${AWS::Partition}:iam::aws:policy/CloudWatchAgentServerPolicy 74 | Path: / 75 | Policies: 76 | - PolicyName: IBMMQSSMLimitedAccess 77 | PolicyDocument: 78 | Version: '2012-10-17' 79 | Statement: 80 | - Effect: Allow 81 | Action: 82 | - ssm:ListCommandInvocations 83 | Resource: '*' 84 | - Effect: Allow 85 | Action: 86 | - logs:FilterLogEvents 87 | Resource: !Sub arn:${AWS::Partition}:logs:*:${AWS::AccountId}:log-group:* 88 | - Effect: Allow 89 | Action: 90 | - ssm:SendCommand 91 | Resource: 92 | - !Sub arn:${AWS::Partition}:ec2:*:${AWS::AccountId}:instance/* 93 | - !Sub arn:${AWS::Partition}:ssm:*:*:document/* 94 | - PolicyName: IBMMQEC2LimitedAccess 95 | PolicyDocument: 96 | Version: 2012-10-17 97 | Statement: 98 | - Effect: Allow 99 | Action: 100 | - ec2:StartInstances 101 | Resource: 102 | - !Sub arn:${AWS::Partition}:license-manager:*:${AWS::AccountId}:license-configuration/* 103 | - !Sub arn:${AWS::Partition}:ec2:*:${AWS::AccountId}:instance/* 104 | - Effect: Allow 105 | Action: 106 | - ec2:DescribeInstances 107 | Resource: '*' 108 | 109 | CleanUpLambda: 110 | Type: AWS::Lambda::Function 111 | Properties: 112 | Code: 113 | ZipFile: | 114 | import boto3 115 | import cfnresponse 116 | import os 117 | import traceback 118 | import time 119 | 120 | def handler(event, context): 121 | responseData = {} 122 | try: 123 | if event['RequestType'] == 'Delete': 124 | print("Run destroy script") 125 | 126 | ssm = boto3.client('ssm', region_name=os.environ['Region']) 127 | ec2 = boto3.resource('ec2') 128 | 129 | instanceID = os.environ['BootNode'] 130 | stackName = os.environ['StackName'] 131 | 132 | instance = ec2.Instance(instanceID) 133 | instance_state = lambda: instance.state.get('Name', 'LAMBDA_ERR') 134 | retries = 18 135 | 136 | while instance_state() != 'running' and retries > 0: 137 | print(f"Boot node is not running (its current state is '{instance_state()}'). Starting now...") 138 | try: 139 | instance.start() 140 | instance.wait_until_running() 141 | except Exception as ex: 142 | print(f"Error when starting boot node: {ex}") 143 | print("Trying again in 10 seconds.") 144 | time.sleep(10) 145 | 146 | instance.reload() 147 | retries = retries - 1 148 | 149 | # We're looping here because it can take a while for the 150 | # SSM agent to start up on the boot node. Once the command 151 | # is successfully sent, we break and move on. 152 | while True: 153 | try: 154 | response = ssm.send_command(Targets=[{"Key":"instanceids","Values":[instanceID]}], 155 | DocumentName="AWS-RunShellScript", 156 | Parameters={"commands":[f"/opt/ibm/scripts/destroy.sh >> /opt/ibm/eksctl.log"], 157 | "executionTimeout":["1800"], 158 | "workingDirectory":["/opt/ibm/scripts"]}, 159 | Comment="Execute script to delete EKS cluster", 160 | TimeoutSeconds=180) 161 | break 162 | except Exception as ex: 163 | print("Error:", ex) 164 | print("Trying again in 10 seconds...") 165 | time.sleep(10) 166 | 167 | print("Response:", response) 168 | command_id = response['Command']['CommandId'] 169 | current_status = 'Pending' 170 | command_in_progress = lambda: current_status in ('Pending', 'InProgress') 171 | 172 | while command_in_progress(): 173 | print("Checking on SSM command status...") 174 | invocations = ssm.list_command_invocations( 175 | CommandId=command_id, 176 | InstanceId=instanceID, 177 | Details=True 178 | ) 179 | 180 | if len(invocations['CommandInvocations']): 181 | current_status = invocations['CommandInvocations'][0]['Status'] 182 | 183 | print(f"Current status is '{current_status}'.") 184 | if command_in_progress(): time.sleep(30) 185 | else: 186 | if current_status != 'Success': 187 | try: 188 | error = invocations['CommandInvocations'][0]['CommandPlugins'][0]['Output'] 189 | except: 190 | error = 'Unknown error, check SSM command history logs' 191 | 192 | raise RuntimeError(f"SSM command failed with the following error: {error}") 193 | 194 | cfnresponse.send(event, context, cfnresponse.SUCCESS, {}, '') 195 | 196 | except Exception as e: 197 | print(e) 198 | traceback.print_exc() 199 | cfnresponse.send(event, context, cfnresponse.FAILED, {}, '') 200 | Environment: 201 | Variables: 202 | Region: !Ref AWS::Region 203 | BootNode: !Ref BootNodeInstanceId 204 | StackName: !Ref AWS::StackName 205 | Handler: index.handler 206 | Role: !GetAtt 'LambdaExecutionRole.Arn' 207 | Runtime: python3.7 208 | Timeout: 900 209 | 210 | Cleanup: 211 | Type: Custom::Cleanup 212 | Properties: 213 | ServiceToken: !GetAtt 'CleanUpLambda.Arn' 214 | Outputs: 215 | EKSName: 216 | Description: EKS cluster name 217 | Value: !Ref EKSClusterName 218 | EKSUrl: 219 | Description: Link to the EKS cluster 220 | Value: !Join ["",["https://", !Ref "AWS::Region",".console.aws.amazon.com/eks/home?region=",!Ref "AWS::Region","#/clusters/", !Ref EKSClusterName]] 221 | -------------------------------------------------------------------------------- /templates/ibm-mq-ec2-bootnode.template.yaml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion: 2010-09-09 2 | Description: This template creates an EC2 instance which is used to run eksctl and kubectl. (qs-1tss294hj) 3 | Metadata: 4 | AWS::CloudFormation::Interface: 5 | ParameterGroups: 6 | - Label: 7 | default: IAM role configuration 8 | Parameters: 9 | - RoleName 10 | - Label: 11 | default: Boot node configuration 12 | Parameters: 13 | - BootNodeName 14 | - EKSClusterName 15 | - LatestAmiId 16 | - Label: 17 | default: Network configuration 18 | Parameters: 19 | - PublicSubnet1ID 20 | - PublicSubnet2ID 21 | - PublicSubnet3ID 22 | - PrivateSubnet1ID 23 | - PrivateSubnet2ID 24 | - PrivateSubnet3ID 25 | - AvailabilityZone1 26 | - AvailabilityZone2 27 | - AvailabilityZone3 28 | ParameterLabels: 29 | RoleName: 30 | default: Role name 31 | BootNodeName: 32 | default: Boot node name 33 | PublicSubnet1ID: 34 | default: Public subnet 1 ID 35 | PublicSubnet2ID: 36 | default: Public subnet 2 ID 37 | PublicSubnet3ID: 38 | default: Public subnet 3 ID 39 | PrivateSubnet1ID: 40 | default: Private subnet 1 ID 41 | PrivateSubnet2ID: 42 | default: Private subnet 2 ID 43 | PrivateSubnet3ID: 44 | default: Private subnet 3 ID 45 | AvailabilityZone1: 46 | default: Availability Zone 1 ID 47 | AvailabilityZone2: 48 | default: Availability Zone 2 ID 49 | AvailabilityZone3: 50 | default: Availability Zone 3 ID 51 | EKSClusterName: 52 | default: EKS cluster name 53 | LatestAmiId: 54 | default: Latest AMI ID 55 | Parameters: 56 | RoleName: 57 | Description: The name of the role to attach to the boot node. 58 | Type: String 59 | BootNodeName: 60 | Description: The name of the boot node. 61 | Type: String 62 | PublicSubnet1ID: 63 | Description: The ID of the public subnet in Availability Zone 1 for the boot node and EKS cluster (for example, "subnet-9bc642ac"). 64 | Type: String 65 | PublicSubnet2ID: 66 | Description: The ID of the public subnet in Availability Zone 2 for the EKS cluster (for example, "subnet-9bc642ac"). 67 | Type: String 68 | PublicSubnet3ID: 69 | Description: The ID of the public subnet in Availability Zone 3 for the EKS cluster (for example, "subnet-9bc642ac"). 70 | Type: String 71 | PrivateSubnet1ID: 72 | Description: The ID of the private subnet in Availability Zone 1 for the EKS cluster (for example, "subnet-9bc642ac"). 73 | Type: String 74 | PrivateSubnet2ID: 75 | Description: The ID of the private subnet in Availability Zone 2 for the EKS cluster (for example, "subnet-9bc642ac"). 76 | Type: String 77 | PrivateSubnet3ID: 78 | Description: The ID of the private subnet in Availability Zone 3 for the EKS cluster (for example, "subnet-9bc642ac"). 79 | Type: String 80 | AvailabilityZone1: 81 | Description: The name of the Availability Zone 1 for the EKS cluster (for example, "ca-central-1a"). 82 | Type: String 83 | AvailabilityZone2: 84 | Description: The name of the Availability Zone 2 for the EKS cluster (for example, "ca-central-1b"). 85 | Type: String 86 | AvailabilityZone3: 87 | Description: The name of the Availability Zone 3 for the EKS cluster (for example, "ca-central-1c"). 88 | Type: String 89 | EKSClusterName: 90 | Type: String 91 | Description: Name of the new EKS cluster (length 2-250) (required). The name must start with a letter and contain only lowercase letters, numbers, hyphens, underscores, periods, and forward slashes. 92 | MinLength: 2 93 | MaxLength: 250 94 | AllowedPattern: (?:[a-z0-9]+(?:[._-][a-z0-9]+)*/)*[a-z0-9]+(?:[._-][a-z0-9]+)* 95 | ConstraintDescription: The name must start with a letter and can only contain lowercase letters, numbers, hyphens, underscores, periods and forward slashes. 96 | LatestAmiId: 97 | Description: Latest Amazon Linux 2 AMI ID from SSM Parameter Store. 98 | Type: 'AWS::SSM::Parameter::Value' 99 | Default: '/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2' 100 | 101 | Resources: 102 | BootNodeProfile: 103 | Type: AWS::IAM::InstanceProfile 104 | Properties: 105 | Roles: 106 | - !Ref RoleName 107 | Path: / 108 | BootNode: 109 | Type: AWS::EC2::Instance 110 | Metadata: 111 | AWS::CloudFormation::Init: 112 | configSets: 113 | Required: 114 | - StackPropertiesFile 115 | StackPropertiesFile: 116 | commands: 117 | 01_create_opt_ibm: 118 | command: mkdir -p /opt/ibm 119 | test: test ! -d /opt/ibm 120 | files: 121 | /opt/ibm/cluster.yaml: 122 | mode: '000755' 123 | owner: root 124 | group: root 125 | content: 126 | !Sub 127 | - | 128 | apiVersion: eksctl.io/v1alpha5 129 | kind: ClusterConfig 130 | metadata: 131 | name: ${ClusterName} 132 | region: ${AWS::Region} 133 | vpc: 134 | subnets: 135 | private: 136 | ${AZ1}: { id: ${PrivateSubnet1ID} } 137 | ${AZ2}: { id: ${PrivateSubnet2ID} } 138 | ${AZ3}: { id: ${PrivateSubnet3ID} } 139 | public: 140 | ${AZ1}: { id: ${PublicSubnet1ID} } 141 | ${AZ2}: { id: ${PublicSubnet2ID} } 142 | ${AZ3}: { id: ${PublicSubnet3ID} } 143 | managedNodeGroups: 144 | - name: ng-1-workers 145 | instanceType: m5.large 146 | desiredCapacity: 3 147 | - AZ1: !Ref AvailabilityZone1 148 | AZ2: !Ref AvailabilityZone2 149 | AZ3: !Ref AvailabilityZone3 150 | PrivateSubnet1ID: !Ref PrivateSubnet1ID 151 | PrivateSubnet2ID: !Ref PrivateSubnet2ID 152 | PrivateSubnet3ID: !Ref PrivateSubnet3ID 153 | PublicSubnet1ID: !Ref PublicSubnet1ID 154 | PublicSubnet2ID: !Ref PublicSubnet2ID 155 | PublicSubnet3ID: !Ref PublicSubnet3ID 156 | ClusterName: !Ref EKSClusterName 157 | 158 | Properties: 159 | ImageId: !Ref LatestAmiId 160 | InstanceType: t2.micro 161 | IamInstanceProfile: !Ref BootNodeProfile 162 | SubnetId: !Ref PublicSubnet1ID 163 | Tags: 164 | - Key: "Name" 165 | Value: !Ref BootNodeName 166 | UserData: 167 | Fn::Base64: 168 | !Sub | 169 | #!/bin/bash 170 | /opt/aws/bin/cfn-init -v --stack ${AWS::StackName} --resource BootNode --configsets Required --region ${AWS::Region} 171 | i=0 172 | while [ ! -f /opt/ibm/cluster.yaml ]; do 173 | echo "/opt/ibm/cluster.yaml isn't available yet, waiting" 174 | sleep 5 175 | i=$[$i+1] 176 | if [ $i -ge 12 ]; then 177 | echo "Timed out waiting 60 seconds for /opt/ibm/cluster.yaml to be available" 178 | break; 179 | fi 180 | echo "/opt/ibm/cluster.yaml ready:" 181 | cat /opt/ibm/cluster.yaml 182 | done 183 | /opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource BootNode --region ${AWS::Region} 184 | 185 | Outputs: 186 | InstanceId: 187 | Description: The instance ID of the boot node 188 | Value: !Ref BootNode 189 | InstanceName: 190 | Description: The name of the boot node 191 | Value: !Ref BootNodeName 192 | User: 193 | Description: The user of the boot node 194 | Value: "ec2-user" 195 | -------------------------------------------------------------------------------- /templates/ibm-mq-eks-workload.template.yaml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion: 2010-09-09 2 | Description: This template installs IBM MQ on EKS cluster. (qs-1tss294hd) 3 | Metadata: 4 | LICENSE: Apache License, Version 2.0 5 | AWS::CloudFormation::Interface: 6 | ParameterGroups: 7 | - Label: 8 | default: EKS configuration 9 | Parameters: 10 | - EKSClusterName 11 | - AdditionalEKSAdminArns 12 | - Label: 13 | default: Application configuration 14 | Parameters: 15 | - AppNamespace 16 | - QSS3CodeLocation 17 | - MQAppPassword 18 | - MQAdminPassword 19 | - InternalLoadBalancer 20 | - Label: 21 | default: Boot node configuration 22 | Parameters: 23 | - BootNodeInstanceId 24 | - BootNodeUser 25 | - Label: 26 | default: Other configuration 27 | Parameters: 28 | - MainStackName 29 | ParameterLabels: 30 | AppNamespace: 31 | default: EKS namespace to deploy the app 32 | EKSClusterName: 33 | default: EKS cluster name 34 | MQAdminPassword: 35 | default: MQ admin password 36 | MQAppPassword: 37 | default: MQ app password 38 | InternalLoadBalancer: 39 | default: Setup internal Load Balancer 40 | BootNodeInstanceId: 41 | default: Boot node 42 | BootNodeUser: 43 | default: Boot node login user 44 | AdditionalEKSAdminArns: 45 | default: Additional EKS administrator ARNs (IAM users or roles) 46 | QSS3CodeLocation: 47 | default: Quick Start S3 location 48 | MainStackName: 49 | default: Main stack name 50 | Parameters: 51 | AppNamespace: 52 | Type: String 53 | Default: "default" 54 | Description: Namespace in the EKS cluster where app will be deployed. 55 | MQAppPassword: 56 | Type: String 57 | NoEcho: true 58 | Description: App password for IBM MQ deployment 59 | MQAdminPassword: 60 | Type: String 61 | NoEcho: true 62 | Description: Admin password for IBM MQ deployment 63 | InternalLoadBalancer: 64 | Type: String 65 | Default: "true" 66 | AllowedValues: [ "true", "false" ] 67 | Description: Choose "false" to create public Load Balancer 68 | BootNodeInstanceId: 69 | Type: AWS::EC2::Instance::Id 70 | Description: Boot Node Instance Id 71 | BootNodeUser: 72 | Type: String 73 | Default: "ec2-user" 74 | Description: Boot Node User 75 | EKSClusterName: 76 | Type: String 77 | Description: Name for the new cluster (required). 78 | QSS3CodeLocation: 79 | Type: String 80 | Description: The S3 location for your copy of the Quick Start assets. 81 | AdditionalEKSAdminArns: 82 | Default: "" 83 | Description: >- 84 | (Optional) A comma-delimited list of IAM user or role Amazon Resource Names (ARNs) 85 | to be granted administrative access to the Amazon EKS cluster. For example, grant 86 | access to two users with their ARNs: "arn:aws:iam::012345678910:user/user1@example.com, 87 | arn:aws:iam::012345678910:user/user2@example.com" 88 | Type: String 89 | MainStackName: 90 | Type: String 91 | Description: The name of the main (parent) stack. This is used to title the CloudWatch log group to which installation output is written. 92 | 93 | Resources: 94 | MQURLParameter: 95 | Type: AWS::SSM::Parameter 96 | Properties: 97 | Type: String 98 | Value: TBD 99 | Description: SSM Parameter for storing MQ Console URL 100 | InstallMQ: 101 | Type: AWS::SSM::Association 102 | Properties: 103 | Name: AWS-RunShellScript 104 | Targets: 105 | - Key: InstanceIds 106 | Values: 107 | - !Ref BootNodeInstanceId 108 | Parameters: 109 | commands: 110 | - !Sub | 111 | #!/bin/bash 112 | aws s3 cp ${QSS3CodeLocation} . --recursive 113 | echo "APPLICATION_NAMESPACE=${AppNamespace}" > scripts/ibm-mq-parameters.properties 114 | echo "APP_PASSWORD=${MQAppPassword}" >> scripts/ibm-mq-parameters.properties 115 | echo "ADMIN_PASSWORD=${MQAdminPassword}" >> scripts/ibm-mq-parameters.properties 116 | echo "INTERNAL_LOAD_BALANCER=${InternalLoadBalancer}" >> scripts/ibm-mq-parameters.properties 117 | echo "AWS_DEFAULT_REGION=${AWS::Region}" >> scripts/ibm-mq-parameters.properties 118 | echo "BOOTNODE_INSTANCE_ID=${BootNodeInstanceId}" >> scripts/ibm-mq-parameters.properties 119 | echo "BOOTNODE_USER=${BootNodeUser}" >> scripts/ibm-mq-parameters.properties 120 | echo "EKS_ADMIN_USER_ARNS='${AdditionalEKSAdminArns}'" >> scripts/ibm-mq-parameters.properties 121 | echo "EKS_CLUSTER_NAME=${EKSClusterName}" >> scripts/ibm-mq-parameters.properties 122 | echo "MQURL_SSM_PARAMETER=${MQURLParameter}" >> scripts/ibm-mq-parameters.properties 123 | 124 | echo "deploying IBM MQ" 125 | 126 | chmod 755 ./scripts/*.sh 127 | echo > install.log 128 | 129 | chown -R ${BootNodeUser} /opt/ibm 130 | chgrp -R ${BootNodeUser} /opt/ibm 131 | su - ${BootNodeUser} -c '/opt/ibm/scripts/install.sh' | tee install.log 132 | 133 | workingDirectory: 134 | - /opt/ibm 135 | WaitForSuccessTimeoutSeconds: 1200 136 | 137 | Outputs: 138 | EKSName: 139 | Description: EKS Cluster name 140 | Value: !Ref EKSClusterName 141 | CloudWatchInstallLogs: 142 | Description: CloudWatch Install Logs 143 | Value: !Join ["",["https://", !Ref "AWS::Region",".console.aws.amazon.com/cloudwatch/home?region=",!Ref "AWS::Region","#logsV2:log-groups/log-group/", !Ref "MainStackName"]] 144 | DeploymentProperties: 145 | Description: Deployment properties 146 | Value: !Join ["",["https://", !Ref "AWS::Region",".console.aws.amazon.com/cloudwatch/home?region=",!Ref "AWS::Region","#logsV2:log-groups/log-group/", !Ref "MainStackName","/log-events/deployment.properties"]] 147 | MQURLParameterName: 148 | Description: Name of the SSM parameter that stores MQ Console URL 149 | Value: !Ref MQURLParameter 150 | MQURLParameterValue: 151 | Description: MQ Console URL parameter value, should be the console URL. If TBD, use the CLI or AWS Console to get the latest. 152 | Value: !GetAtt MQURLParameter.Value -------------------------------------------------------------------------------- /templates/ibm-mq-iam-role.template.yaml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion: 2010-09-09 2 | Description: This template creates an IAM role which can be attached to an EC2 instance profile to enable EKS cluster creation with eksctl. Based on https://eksctl.io/usage/minimum-iam-policies/. (qs-1tss294h4) 3 | Metadata: 4 | AWS::CloudFormation::Interface: 5 | ParameterGroups: 6 | - Label: 7 | default: IAM role configuration 8 | Parameters: 9 | - RoleName 10 | ParameterLabels: 11 | RoleName: 12 | default: Role name 13 | Parameters: 14 | RoleName: 15 | Description: The name to give to the role. 16 | Default: IBMMQDeploymentRole 17 | Type: String 18 | Resources: 19 | IBMMQDeploymentRole: 20 | Type: AWS::IAM::Role 21 | Metadata: 22 | cfn-lint: 23 | config: 24 | ignore_checks: 25 | - EIAMPolicyWildcardResource 26 | ignore_reasons: 27 | - EIAMPolicyWildcardResource: "eks ListClusters, DescribeAddonVersions, RegisterCluster, CreateCluster only allow wildcard resource." 28 | Properties: 29 | RoleName: !Ref RoleName 30 | AssumeRolePolicyDocument: 31 | Statement: 32 | - Action: 'sts:AssumeRole' 33 | Principal: 34 | Service: !Sub ec2.${AWS::URLSuffix} 35 | Effect: Allow 36 | Sid: '' 37 | ManagedPolicyArns: 38 | - !Sub arn:${AWS::Partition}:iam::aws:policy/AmazonEC2FullAccess 39 | - !Sub arn:${AWS::Partition}:iam::aws:policy/AWSCloudFormationFullAccess 40 | - !Sub arn:${AWS::Partition}:iam::aws:policy/AmazonSSMManagedInstanceCore 41 | - !Sub arn:${AWS::Partition}:iam::aws:policy/AmazonS3ReadOnlyAccess 42 | - !Sub arn:${AWS::Partition}:iam::aws:policy/CloudWatchAgentServerPolicy 43 | Policies: 44 | - PolicyName: IBMMQEKSFullAccess 45 | PolicyDocument: 46 | Version: 2012-10-17 47 | Statement: 48 | - Effect: Allow 49 | Action: 50 | - eks:ListClusters 51 | - eks:DescribeAddonVersions 52 | - eks:RegisterCluster 53 | - eks:CreateCluster 54 | Resource: '*' 55 | - Effect: Allow 56 | Action: 57 | - eks:DeleteFargateProfile 58 | - eks:UpdateClusterVersion 59 | - eks:DescribeFargateProfile 60 | - eks:ListTagsForResource 61 | - eks:UpdateAddon 62 | - eks:ListAddons 63 | - eks:UpdateClusterConfig 64 | - eks:DescribeAddon 65 | - eks:UpdateNodegroupVersion 66 | - eks:DescribeNodegroup 67 | - eks:AssociateEncryptionConfig 68 | - eks:ListUpdates 69 | - eks:ListIdentityProviderConfigs 70 | - eks:ListNodegroups 71 | - eks:DisassociateIdentityProviderConfig 72 | - eks:UntagResource 73 | - eks:CreateNodegroup 74 | - eks:DeregisterCluster 75 | - eks:DeleteCluster 76 | - eks:CreateFargateProfile 77 | - eks:ListFargateProfiles 78 | - eks:DescribeIdentityProviderConfig 79 | - eks:DeleteAddon 80 | - eks:DeleteNodegroup 81 | - eks:DescribeUpdate 82 | - eks:TagResource 83 | - eks:AccessKubernetesApi 84 | - eks:CreateAddon 85 | - eks:UpdateNodegroupConfig 86 | - eks:DescribeCluster 87 | - eks:AssociateIdentityProviderConfig 88 | Resource: 89 | - !Sub arn:${AWS::Partition}:eks:*:${AWS::AccountId}:identityproviderconfig/*/*/*/* 90 | - !Sub arn:${AWS::Partition}:eks:*:${AWS::AccountId}:cluster/* 91 | - !Sub arn:${AWS::Partition}:eks:*:${AWS::AccountId}:nodegroup/*/*/* 92 | - !Sub arn:${AWS::Partition}:eks:*:${AWS::AccountId}:addon/*/*/* 93 | - !Sub arn:${AWS::Partition}:eks:*:${AWS::AccountId}:fargateprofile/*/*/* 94 | - Effect: Allow 95 | Action: 96 | - ssm:GetParameter 97 | - ssm:GetParameters 98 | - ssm:PutParameter 99 | Resource: !Sub arn:${AWS::Partition}:ssm:*:${AWS::AccountId}:parameter/* 100 | - Effect: Allow 101 | Action: 102 | - kms:CreateGrant 103 | - kms:DescribeKey 104 | Resource: !Sub arn:${AWS::Partition}:kms:*:${AWS::AccountId}:key/* 105 | - Effect: Allow 106 | Action: logs:PutRetentionPolicy 107 | Resource: !Sub arn:${AWS::Partition}:logs:*:${AWS::AccountId}:log-group:* 108 | - PolicyName: IBMMQIAMLimitedAccess 109 | PolicyDocument: 110 | Version: 2012-10-17 111 | Statement: 112 | - Effect: Allow 113 | Action: 114 | - iam:CreateInstanceProfile 115 | - iam:DeleteInstanceProfile 116 | - iam:GetInstanceProfile 117 | - iam:RemoveRoleFromInstanceProfile 118 | - iam:GetRole 119 | - iam:CreateRole 120 | - iam:DeleteRole 121 | - iam:AttachRolePolicy 122 | - iam:PutRolePolicy 123 | - iam:ListInstanceProfiles 124 | - iam:AddRoleToInstanceProfile 125 | - iam:ListInstanceProfilesForRole 126 | - iam:PassRole 127 | - iam:DetachRolePolicy 128 | - iam:DeleteRolePolicy 129 | - iam:GetRolePolicy 130 | - iam:GetOpenIDConnectProvider 131 | - iam:CreateOpenIDConnectProvider 132 | - iam:DeleteOpenIDConnectProvider 133 | - iam:TagOpenIDConnectProvider 134 | - iam:ListAttachedRolePolicies 135 | - iam:TagRole 136 | - iam:GetPolicy 137 | - iam:CreatePolicy 138 | - iam:DeletePolicy 139 | - iam:ListPolicyVersions 140 | Resource: 141 | - !Sub arn:${AWS::Partition}:iam::${AWS::AccountId}:instance-profile/eksctl-* 142 | - !Sub arn:${AWS::Partition}:iam::${AWS::AccountId}:role/eksctl-* 143 | - !Sub arn:${AWS::Partition}:iam::${AWS::AccountId}:policy/eksctl-* 144 | - !Sub arn:${AWS::Partition}:iam::${AWS::AccountId}:oidc-provider/* 145 | - !Sub arn:${AWS::Partition}:iam::${AWS::AccountId}:role/aws-service-role/eks-nodegroup.amazonaws.com/AWSServiceRoleForAmazonEKSNodegroup 146 | - !Sub arn:${AWS::Partition}:iam::${AWS::AccountId}:role/eksctl-managed-* 147 | - !Sub arn:${AWS::Partition}:iam::${AWS::AccountId}:role/AmazonEKS_EBS_CSI_DriverRole* 148 | - Effect: Allow 149 | Action: 150 | - iam:GetRole 151 | Resource: 152 | - !Sub arn:${AWS::Partition}:iam::${AWS::AccountId}:role/* 153 | - Effect: Allow 154 | Action: 155 | - iam:CreateServiceLinkedRole 156 | Resource: !Sub arn:${AWS::Partition}:iam::${AWS::AccountId}:role/* 157 | Condition: 158 | StringEquals: 159 | iam:AWSServiceName: 160 | - eks.amazonaws.com 161 | - eks-nodegroup.amazonaws.com 162 | - eks-fargate.amazonaws.com 163 | Outputs: 164 | RoleName: 165 | Description: The name of the created role. 166 | Value: !Ref IBMMQDeploymentRole 167 | RoleARN: 168 | Description: The ARN of the created role. 169 | Value: !GetAtt IBMMQDeploymentRole.Arn 170 | RoleURL: 171 | Description: Link to the IAM role. 172 | Value: !Join ["",["https://", !Ref "AWS::Region",".console.aws.amazon.com/iamv2/home?region=",!Ref "AWS::Region","#/roles/details/", !Ref IBMMQDeploymentRole]] 173 | -------------------------------------------------------------------------------- /templates/ibm-mq-main.template.yaml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion: "2010-09-09" 2 | Description: "This template deploys IBM MQ into a new Amazon EKS cluster in a new VPC. (qs-1tss294ep)" 3 | Metadata: 4 | QuickStartDocumentation: 5 | EntrypointName: Deploy IBM MQ in new VPC 6 | Order: 1 7 | LICENSE: Apache License, Version 2.0 8 | LintSpellExclude: 9 | - Partner 10 | - Solution 11 | - ARNs 12 | - namespace 13 | - Load Balancer 14 | - One 15 | - com 16 | - aws 17 | - arn 18 | - myid 19 | - otherid 20 | AWS::CloudFormation::Interface: 21 | ParameterGroups: 22 | - Label: 23 | default: EKS configuration 24 | Parameters: 25 | - EKSClusterName 26 | - AdditionalEKSAdminArns 27 | - AvailabilityZones 28 | - Label: 29 | default: IBM MQ configuration 30 | Parameters: 31 | - AppNamespace 32 | - MQAdminPassword 33 | - MQAppPassword 34 | - InternalLoadBalancer 35 | - Label: 36 | default: AWS Partner Solution configuration 37 | Parameters: 38 | - QSS3BucketName 39 | - QSS3KeyPrefix 40 | - QSS3BucketRegion 41 | ParameterLabels: 42 | EKSClusterName: 43 | default: EKS cluster name 44 | QSS3BucketName: 45 | default: Partner Solution S3 bucket name 46 | QSS3BucketRegion: 47 | default: Partner Solution S3 bucket Region 48 | QSS3KeyPrefix: 49 | default: Partner Solution S3 key prefix 50 | AdditionalEKSAdminArns: 51 | default: Additional EKS administrator ARNs 52 | AvailabilityZones: 53 | default: Availability Zones 54 | AppNamespace: 55 | default: App namespace 56 | MQAdminPassword: 57 | default: MQ admin password 58 | MQAppPassword: 59 | default: MQ app password 60 | InternalLoadBalancer: 61 | default: Setup internal Load Balancer 62 | Parameters: 63 | EKSClusterName: 64 | Type: String 65 | Description: Name of new Amazon EKS cluster (2-250 characters). Name must start with a letter and contain only lowercase letters, numbers, hyphens, underscores, periods, and forward slashes. 66 | MinLength: 2 67 | MaxLength: 250 68 | AllowedPattern: (?:[a-z0-9]+(?:[._-][a-z0-9]+)*/)*[a-z0-9]+(?:[._-][a-z0-9]+)* 69 | ConstraintDescription: The name must start with a letter and contain only lowercase letters, numbers, hyphens, underscores, periods, and forward slashes. 70 | AppNamespace: 71 | Type: String 72 | Default: "default" 73 | Description: Namespace in Amazon EKS cluster where app is deployed. 74 | MQAppPassword: 75 | Type: String 76 | NoEcho: true 77 | Description: App password for IBM MQ deployment. 78 | MQAdminPassword: 79 | Type: String 80 | NoEcho: true 81 | Description: Admin password for IBM MQ deployment. 82 | InternalLoadBalancer: 83 | Type: String 84 | Default: "true" 85 | AllowedValues: ["true", "false"] 86 | Description: Choose false to create public Load Balancer. 87 | QSS3BucketName: 88 | AllowedPattern: ^[0-9a-z]+([0-9a-z-\.]*[0-9a-z])*$ 89 | ConstraintDescription: >- 90 | The S3 bucket name can include numbers, lowercase letters, 91 | and hyphens (-), but it cannot start or end with a hyphen. 92 | Default: aws-quickstart 93 | Description: >- 94 | Name of the S3 bucket for your copy of the deployment assets. Keep the default 95 | name unless you are customizing the template. Changing the name updates code 96 | references to point to a new location. 97 | MinLength: 3 98 | MaxLength: 63 99 | Type: String 100 | QSS3KeyPrefix: 101 | Type: String 102 | Description: >- 103 | S3 key prefix that is used to simulate a folder for your copy of the 104 | deployment assets. Keep the default prefix unless you are customizing 105 | the template. Changing the prefix updates code references to point to 106 | a new location. 107 | AllowedPattern: ^([0-9a-zA-Z!-_\.\*'\(\)/]+/)*$ 108 | ConstraintDescription: >- 109 | The S3 key prefix can include numbers, lowercase letters, uppercase letters, 110 | hyphens (-), underscores (_), periods (.), asterisks (*), single quotes ('), 111 | open parenthesis ((), close parenthesis ()), and forward slashes (/). End the 112 | prefix with a forward slash. 113 | Default: quickstart-ibm-mq/ 114 | QSS3BucketRegion: 115 | Type: String 116 | Description: >- 117 | AWS Region where the S3 bucket (QSS3BucketName) is hosted. Keep 118 | the default Region unless you are customizing the template. Changing the Region 119 | updates code references to point to a new location. When using your own bucket, 120 | specify the Region. 121 | Default: us-east-1 122 | AdditionalEKSAdminArns: 123 | Default: "" 124 | Description: >- 125 | (Optional) One or more IAM user or role ARNs to be granted administrative access to new Amazon EKS cluster. By default, access Amazon EKS cluster from boot node only. To enter multiple ARNs, use comma-delimited list. Example: arn:aws:iam::012345678910:user/myid@example.com, 126 | arn:aws:iam::012345678910:user/otherid@example.com. 127 | Type: String 128 | AvailabilityZones: 129 | Description: Availability Zones to use for subnet in new VPC. You must select 3 Availability Zones. 130 | Type: List 131 | 132 | Conditions: 133 | UsingDefaultBucket: !Equals [!Ref QSS3BucketName, aws-quickstart] 134 | 135 | Resources: 136 | IBMMQIAMRoleStack: 137 | Type: 'AWS::CloudFormation::Stack' 138 | Properties: 139 | TemplateURL: !Sub 140 | - https://${S3Bucket}.s3.${S3Region}.${AWS::URLSuffix}/${QSS3KeyPrefix}templates/ibm-mq-iam-role.template.yaml 141 | - S3Bucket: !If [UsingDefaultBucket, !Sub 'aws-quickstart-${AWS::Region}', !Ref QSS3BucketName] 142 | S3Region: !If [UsingDefaultBucket, !Ref AWS::Region, !Ref QSS3BucketRegion] 143 | Parameters: 144 | RoleName: !Join [ "", [ "ibm-mq-", !Ref EKSClusterName, "-", !Ref "AWS::Region", "-role" ] ] 145 | 146 | IBMMQVPCStack: 147 | Type: AWS::CloudFormation::Stack 148 | Properties: 149 | TemplateURL: !Sub 150 | - https://${S3Bucket}.s3.${S3Region}.${AWS::URLSuffix}/${QSS3KeyPrefix}submodules/quickstart-aws-vpc/templates/aws-vpc.template.yaml 151 | - S3Bucket: !If [ UsingDefaultBucket, !Sub 'aws-quickstart-${AWS::Region}', !Ref QSS3BucketName ] 152 | S3Region: !If [ UsingDefaultBucket, !Ref AWS::Region, !Ref QSS3BucketRegion ] 153 | Parameters: 154 | AvailabilityZones: !Join [ ',', !Ref AvailabilityZones ] 155 | NumberOfAZs: 3 156 | PrivateSubnetATag2: "kubernetes.io/role/internal-elb=" 157 | PublicSubnetTag2: "kubernetes.io/role/elb=" 158 | 159 | IBMMQBootNodeStack: 160 | Type: 'AWS::CloudFormation::Stack' 161 | Properties: 162 | TemplateURL: !Sub 163 | - https://${S3Bucket}.s3.${S3Region}.${AWS::URLSuffix}/${QSS3KeyPrefix}templates/ibm-mq-ec2-bootnode.template.yaml 164 | - S3Bucket: !If [UsingDefaultBucket, !Sub 'aws-quickstart-${AWS::Region}', !Ref QSS3BucketName] 165 | S3Region: !If [UsingDefaultBucket, !Ref AWS::Region, !Ref QSS3BucketRegion] 166 | Parameters: 167 | RoleName: !GetAtt IBMMQIAMRoleStack.Outputs.RoleName 168 | BootNodeName: !Join ["-", [!Ref EKSClusterName, "bootnode"]] 169 | EKSClusterName: !Ref EKSClusterName 170 | PublicSubnet1ID: !GetAtt 'IBMMQVPCStack.Outputs.PublicSubnet1ID' 171 | PublicSubnet2ID: !GetAtt 'IBMMQVPCStack.Outputs.PublicSubnet2ID' 172 | PublicSubnet3ID: !GetAtt 'IBMMQVPCStack.Outputs.PublicSubnet3ID' 173 | AvailabilityZone1: !Select [0, !Ref AvailabilityZones] 174 | AvailabilityZone2: !Select [1, !Ref AvailabilityZones] 175 | AvailabilityZone3: !Select [2, !Ref AvailabilityZones] 176 | PrivateSubnet1ID: !GetAtt 'IBMMQVPCStack.Outputs.PrivateSubnet1AID' 177 | PrivateSubnet2ID: !GetAtt 'IBMMQVPCStack.Outputs.PrivateSubnet2AID' 178 | PrivateSubnet3ID: !GetAtt 'IBMMQVPCStack.Outputs.PrivateSubnet3AID' 179 | 180 | IBMMQEKSClusterStack: 181 | Type: 'AWS::CloudFormation::Stack' 182 | Properties: 183 | TemplateURL: !Sub 184 | - https://${S3Bucket}.s3.${S3Region}.${AWS::URLSuffix}/${QSS3KeyPrefix}templates/ibm-mq-create-eks.template.yaml 185 | - S3Bucket: !If [UsingDefaultBucket, !Sub 'aws-quickstart-${AWS::Region}', !Ref QSS3BucketName] 186 | S3Region: !If [UsingDefaultBucket, !Ref AWS::Region, !Ref QSS3BucketRegion] 187 | Parameters: 188 | BootNodeInstanceId: !GetAtt IBMMQBootNodeStack.Outputs.InstanceId 189 | EKSClusterName: !Ref EKSClusterName 190 | 191 | IBMMQWorkloadStack: 192 | Type: 'AWS::CloudFormation::Stack' 193 | DependsOn: 194 | - IBMMQEKSClusterStack 195 | Properties: 196 | TemplateURL: !Sub 197 | - https://${S3Bucket}.s3.${S3Region}.${AWS::URLSuffix}/${QSS3KeyPrefix}templates/ibm-mq-eks-workload.template.yaml 198 | - S3Bucket: !If [UsingDefaultBucket, !Sub 'aws-quickstart-${AWS::Region}', !Ref QSS3BucketName] 199 | S3Region: !If [UsingDefaultBucket, !Ref AWS::Region, !Ref QSS3BucketRegion] 200 | Parameters: 201 | BootNodeInstanceId: !GetAtt IBMMQBootNodeStack.Outputs.InstanceId 202 | BootNodeUser: !GetAtt IBMMQBootNodeStack.Outputs.User 203 | EKSClusterName: !Ref EKSClusterName 204 | MainStackName: !Ref "AWS::StackName" 205 | AppNamespace: !Ref AppNamespace 206 | MQAdminPassword: !Ref MQAdminPassword 207 | MQAppPassword: !Ref MQAppPassword 208 | InternalLoadBalancer: !Ref InternalLoadBalancer 209 | QSS3CodeLocation: !Sub 210 | - s3://${S3Bucket}/${QSS3KeyPrefix} 211 | - S3Bucket: !If [UsingDefaultBucket, !Sub 'aws-quickstart-${AWS::Region}', !Ref QSS3BucketName] 212 | AdditionalEKSAdminArns: !Ref AdditionalEKSAdminArns 213 | 214 | Outputs: 215 | EKSClusterName: 216 | Description: EKS cluster name. 217 | Value: !Ref EKSClusterName 218 | MQURLParameterName: 219 | Description: Name of SSM parameter that stores MQ console URL. 220 | Value: !GetAtt IBMMQWorkloadStack.Outputs.MQURLParameterName 221 | MQURLParameterValue: 222 | Description: MQ console URL parameter value, should be console URL. If TBD, use CLI or AWS Console to get latest. 223 | Value: !GetAtt IBMMQWorkloadStack.Outputs.MQURLParameterValue 224 | BootNodeInstanceId: 225 | Description: Boot node EC2 instance ID. 226 | Value: !GetAtt IBMMQBootNodeStack.Outputs.InstanceId 227 | BootNodeName: 228 | Description: Boot node name. 229 | Value: !GetAtt IBMMQBootNodeStack.Outputs.InstanceName 230 | InstallLogsLocation: 231 | Description: Install logs location (on boot node). 232 | Value: "/opt/ibm/install.log" 233 | CloudWatchInstallLogs: 234 | Description: Installation logs (in CloudWatch). 235 | Value: !GetAtt IBMMQWorkloadStack.Outputs.CloudWatchInstallLogs 236 | DeploymentProperties: 237 | Description: Deployment properties. 238 | Value: !GetAtt IBMMQWorkloadStack.Outputs.DeploymentProperties 239 | EKSClusterVpcId: 240 | Description: ID of VPC created for your Amazon EKS cluster. 241 | Value: !GetAtt IBMMQVPCStack.Outputs.VPCID 242 | EKSClusterVpcUrl: 243 | Description: URL to manage VPC created for your Amazon EKS cluster. 244 | Value: !Join ["", ["https://", !Ref "AWS::Region", ".console.aws.amazon.com/vpc/home?region=", !Ref "AWS::Region", "#VpcDetails:VpcId=", !GetAtt IBMMQVPCStack.Outputs.VPCID]] 245 | IAMRoleName: 246 | Description: Role name to manage Amazon EKS. 247 | Value: !GetAtt IBMMQIAMRoleStack.Outputs.RoleName 248 | IAMRoleUrl: 249 | Description: URL to view IAM role used to create Amazon EKS cluster. 250 | Value: !GetAtt IBMMQIAMRoleStack.Outputs.RoleURL 251 | --------------------------------------------------------------------------------