Skip to content

Commit ff80ed4

Browse files
committed
R2024a release!
1 parent c5d5909 commit ff80ed4

36 files changed

+3721
-4120
lines changed

packer/v1/build-matlab-ami.pkr.hcl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2024 The MathWorks Inc.
1+
# Copyright 2024 The MathWorks, Inc.
22

33
variable "RELEASE" {
44
type = string

packer/v1/build/Enable-OpenSSh.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse
1313
1414
.NOTES
15-
Copyright 2023 The MathWorks Inc.
15+
Copyright 2023-2024 The MathWorks, Inc.
1616
The function sets $ErrorActionPreference to 'Stop' to ensure that any errors encountered during the installation process will cause the script to stop and throw an error.
1717
#>
1818

packer/v1/build/Install-Dependencies.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
The URL for the NICE DCV installer.
1313
1414
.NOTES
15-
Copyright 2023 The MathWorks Inc.
15+
Copyright 2023-2024 The MathWorks, Inc.
1616
The function sets $ErrorActionPreference to 'Stop' to ensure that any errors encountered during the installation process will cause the script to stop and throw an error.
1717
#>
1818

packer/v1/build/Install-MATLAB.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/main/MPM.md
77
88
.NOTES
9-
Copyright 2020-2024 The MathWorks Inc.
9+
Copyright 2020-2024 The MathWorks, Inc.
1010
The function sets $ErrorActionPreference to 'Stop' to ensure that any errors encountered during the installation process will cause the script to stop and throw an error.
1111
#>
1212

packer/v1/build/Install-MATLABProxy.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
https://github.com/mathworks/matlab-proxy
1616
1717
.NOTES
18-
Copyright 2024 The MathWorks Inc.
18+
Copyright 2024 The MathWorks, Inc.
1919
The function sets $ErrorActionPreference to 'Stop' to ensure that any errors encountered during the installation process will cause the script to stop and throw an error.
2020
#>
2121

packer/v1/build/Install-NVIDIADrivers.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
.LINK
1717
https://uk.mathworks.com/help/parallel-computing/gpu-computing-requirements.html
1818
.NOTES
19-
Copyright 2023 The MathWorks Inc.
19+
Copyright 2023-2024 The MathWorks, Inc.
2020
The function sets $ErrorActionPreference to 'Stop' to ensure that any errors encountered during the installation process will cause the script to stop and throw an error.
2121
#>
2222

packer/v1/build/Install-StartupScripts.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
Install-StartupScripts
1010
1111
.NOTES
12-
Copyright 2023 The MathWorks Inc.
12+
Copyright 2023-2024 The MathWorks, Inc.
1313
The function sets $ErrorActionPreference to 'Stop' to ensure that any errors encountered during the installation process will cause the script to stop and throw an error.
1414
#>
1515
function Install-StartupScripts {

packer/v1/build/Invoke-Sysprep.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
Invoke-Sysprep
1111
1212
.NOTES
13-
Copyright 2023 The MathWorks Inc.
13+
Copyright 2023-2024 The MathWorks, Inc.
1414
The function sets $ErrorActionPreference to 'Stop' to ensure that any errors encountered during the installation process will cause the script to stop and throw an error.
1515
#>
1616
function Invoke-Sysprep {

packer/v1/build/Remove-IE.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
Remove-IE
1010
1111
.NOTES
12-
Copyright 2023 The MathWorks Inc.
12+
Copyright 2023-2024 The MathWorks, Inc.
1313
The function sets $ErrorActionPreference to 'Stop' to ensure that any errors encountered during the installation process will cause the script to stop and throw an error.
1414
#>
1515
function Remove-IE {

packer/v1/build/Remove-TemporaryFiles.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
Remove-TemporaryBuildFiles
1010
1111
.NOTES
12-
Copyright 2023 The MathWorks Inc.
12+
Copyright 2023-2024 The MathWorks, Inc.
1313
The function sets $ErrorActionPreference to 'Stop' to ensure that any errors encountered during the installation process will cause the script to stop and throw an error.
1414
#>
1515

packer/v1/build/config/matlab/generate_toolbox_cache.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2023 The MathWorks Inc.
1+
# Copyright 2023-2024 The MathWorks, Inc.
22
"""! @brief Python program to generate the toolbox-cache xml for MATLAB
33
44
generate_toolbox_cache.py file takes matlabroot and toolbox-cache xml destination folder as inputs,

packer/v1/build/config/matlab/startup-accelerator/R2024a/msa.ini

+3,667-4,068
Large diffs are not rendered by default.

packer/v1/build/config/packer/bootstrap_win.pkrtpl.hcl

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<powershell>
2+
# Copyright 2024 The MathWorks, Inc.
3+
#
24
# This script is executed by Packer during deployment of the build instance.
35
# It enables WinRM, which Packer uses to provision the instance.
46

packer/v1/release-config/R2020b.pkrvars.hcl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2024 The MathWorks Inc.
1+
# Copyright 2024 The MathWorks, Inc.
22

33
// Use this Packer configuration file to build AMI with R2020b MATLAB installed.
44
// For more information on these variables, see /packer/build-matlab-ami.pkr.hcl.

packer/v1/release-config/R2021a.pkrvars.hcl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2024 The MathWorks Inc.
1+
# Copyright 2024 The MathWorks, Inc.
22

33
// Use this Packer configuration file to build AMI with R2021a MATLAB installed.
44
// For more information on these variables, see /packer/build-matlab-ami.pkr.hcl.

packer/v1/release-config/R2021b.pkrvars.hcl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2024 The MathWorks Inc.
1+
# Copyright 2024 The MathWorks, Inc.
22

33
// Use this Packer configuration file to build AMI with R2021b MATLAB installed.
44
// For more information on these variables, see /packer/build-matlab-ami.pkr.hcl.

packer/v1/release-config/R2022a.pkrvars.hcl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2024 The MathWorks Inc.
1+
# Copyright 2024 The MathWorks, Inc.
22

33
// Use this Packer configuration file to build AMI with R2022a MATLAB installed.
44
// For more information on these variables, see /packer/build-matlab-ami.pkr.hcl.

packer/v1/release-config/R2022b.pkrvars.hcl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2024 The MathWorks Inc.
1+
# Copyright 2024 The MathWorks, Inc.
22

33
// Use this Packer configuration file to build AMI with R2022b MATLAB installed.
44
// For more information on these variables, see /packer/build-matlab-ami.pkr.hcl.

packer/v1/release-config/R2023a.pkrvars.hcl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2024 The MathWorks Inc.
1+
# Copyright 2024 The MathWorks, Inc.
22

33
// Use this Packer configuration file to build AMI with R2023a MATLAB installed.
44
// For more information on these variables, see /packer/build-matlab-ami.pkr.hcl.

packer/v1/release-config/R2023b.pkrvars.hcl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2024 The MathWorks Inc.
1+
# Copyright 2024 The MathWorks, Inc.
22

33
// Use this Packer configuration file to build AMI with R2023b MATLAB installed.
44
// For more information on these variables, see /packer/build-matlab-ami.pkr.hcl.

packer/v1/release-config/R2024a.pkrvars.hcl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2024 The MathWorks Inc.
1+
# Copyright 2024 The MathWorks, Inc.
22

33
// Use this Packer configuration file to build AMI with R2024a MATLAB installed.
44
// For more information on these variables, see /packer/build-matlab-ami.pkr.hcl.

packer/v1/runtime/Install-NVIDIAGridDriver.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/install-nvidia-driver.html
2121
2222
.NOTES
23-
Copyright 2023 The MathWorks Inc.
23+
Copyright 2023-2024 The MathWorks, Inc.
2424
The function sets $ErrorActionPreference to 'Stop' to ensure that any errors encountered during the installation process will cause the script to stop and throw an error.
2525
#>
2626

packer/v1/runtime/Start-MATLABProxy.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
https://github.com/mathworks/matlab-proxy/blob/main/Advanced-Usage.md
1313
1414
.NOTES
15-
Copyright 2024 The MathWorks Inc.
15+
Copyright 2024 The MathWorks, Inc.
1616
This script is invoked by Task Scheduler only.
1717
#>
1818
function Start-MATLABProxy {

packer/v1/runtime/generate-certificate.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2024 The MathWorks Inc.
1+
# Copyright 2024 The MathWorks, Inc.
22

33
import os
44
from cryptography import x509

packer/v1/startup/00_Confirm-InstanceProfile.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
Confirm-InstanceProfile
1111
1212
.NOTES
13-
Copyright 2020-2024 The MathWorks Inc.
13+
Copyright 2020-2024 The MathWorks, Inc.
1414
#>
1515
function Confirm-InstanceProfile {
1616

packer/v1/startup/10_Initialize-EBSVolume.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ebs-using-volumes.html
1414
1515
.NOTES
16-
Copyright 2023 The MathWorks Inc.
16+
Copyright 2023-2024 The MathWorks, Inc.
1717
#>
1818
function Initialize-EBSVolume {
1919

packer/v1/startup/20_Set-AdminPassword.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
Set-AdminPassword -AdminPass "<ADMIN_PASSWORD>"
1313
1414
.NOTES
15-
Copyright 2023 The MathWorks Inc.
15+
Copyright 2023-2024 The MathWorks, Inc.
1616
#>
1717
function Set-AdminPassword {
1818

packer/v1/startup/30_Initialize-CloudWatchLogging.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/create-cloudwatch-agent-configuration-file.html
1717
1818
.NOTES
19-
Copyright 2023 The MathWorks Inc.
19+
Copyright 2023-2024 The MathWorks, Inc.
2020
#>
2121

2222
function Initialize-CloudWatchLogging {

packer/v1/startup/40_Set-DDUX.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
Set-DDUX
1212
1313
.NOTES
14-
Copyright 2020-2024 The MathWorks Inc.
14+
Copyright 2020-2024 The MathWorks, Inc.
1515
#>
1616
function Set-DDUX {
1717

packer/v1/startup/50_Setup-MATLABProxy.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
Set-MATLABProxy -EnableBrowserAccess "Yes" -AuthToken "<AUTH-TOKEN>"
1919
2020
.NOTES
21-
Copyright 2024 The MathWorks Inc.
21+
Copyright 2024 The MathWorks, Inc.
2222
#>
2323

2424
function Set-MATLABProxy {

packer/v1/startup/60_Set-MATLABLicense.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
Set-MATLABLicense -MATLABRoot "<MATLAB_ROOT_FOLDER>" -MLMLicenseFile "<PATH_TO_MATLAB_LICENSE_FILE>"
1616
1717
.NOTES
18-
Copyright 2023 The MathWorks Inc.
18+
Copyright 2023-2024 The MathWorks, Inc.
1919
#>
2020

2121
function Set-MATLABLicense {

packer/v1/startup/70_Invoke-MATLABStartupAccelerator.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
Invoke-MATLABStartupAccelerator -MATLABRoot "<MATLAB_ROOT_FOLDER>"
1313
1414
.NOTES
15-
Copyright 2020-2024 The MathWorks Inc.
15+
Copyright 2020-2024 The MathWorks, Inc.
1616
#>
1717

1818
function Invoke-MATLABStartupAccelerator {

packer/v1/startup/80_Invoke-MSHStartupAccelerator.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
Invoke-MSHStartupAccelerator -MATLABRoot "<MATLAB_ROOT_FOLDER>"
1313
1414
.NOTES
15-
Copyright 2024 The MathWorks Inc.
15+
Copyright 2024 The MathWorks, Inc.
1616
#>
1717

1818
function Invoke-MSHStartupAccelerator {

packer/v1/startup/99_Invoke-OptionalUserCommand.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
Invoke-OptionalUserCommand -UserCommand "<OPTIONAL_USER_COMMAND>"
1414
1515
.NOTES
16-
Copyright 2023-2024 The MathWorks Inc.
16+
Copyright 2023-2024 The MathWorks, Inc.
1717
#>
1818

1919
function Invoke-OptionalUserCommand {

packer/v1/startup/env.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# Copyright 2022 The MathWorks Inc.
1+
# Copyright 2022-2024 The MathWorks, Inc.
22

33
$Env:MATLABRoot = (Get-Item (Get-Command matlab).Path).Directory.Parent.FullName

releases/R2024a/aws-matlab-template.json

+19-19
Original file line numberDiff line numberDiff line change
@@ -3,58 +3,58 @@
33
"Mappings": {
44
"RegionMap": {
55
"us-east-1": {
6-
"AMI": "ami-0b87d6d6549d6cf05"
6+
"AMI": "ami-0d6ee2886bd244da5"
77
},
88
"us-east-2": {
9-
"AMI": "ami-0897405d466f70917"
9+
"AMI": "ami-008bfa65989701e8e"
1010
},
1111
"us-west-1": {
12-
"AMI": "ami-08274e280c8adeb41"
12+
"AMI": "ami-0db27e770f106e446"
1313
},
1414
"us-west-2": {
15-
"AMI": "ami-0475ad550a49c0b32"
15+
"AMI": "ami-05612b746689f9b15"
1616
},
1717
"ca-central-1": {
18-
"AMI": "ami-0c552748a47926287"
18+
"AMI": "ami-0b0b3953456f25d6e"
1919
},
2020
"eu-central-1": {
21-
"AMI": "ami-0f0c16d879e0ea850"
21+
"AMI": "ami-07d555f7d8c193979"
2222
},
2323
"eu-west-1": {
24-
"AMI": "ami-09df159ef808ed76e"
24+
"AMI": "ami-0ddfa5404f0146080"
2525
},
2626
"eu-west-2": {
27-
"AMI": "ami-062148e3a494da1dd"
27+
"AMI": "ami-0347d4454a92a157c"
2828
},
2929
"eu-west-3": {
30-
"AMI": "ami-06ff6af6d123de5f9"
30+
"AMI": "ami-081f8109743149f39"
3131
},
3232
"eu-north-1": {
33-
"AMI": "ami-0acd50010ef1e1164"
33+
"AMI": "ami-0999d0a078a2f56bf"
3434
},
3535
"sa-east-1": {
36-
"AMI": "ami-007af0068115c5ffa"
36+
"AMI": "ami-023d0c38acceed5b2"
3737
},
3838
"me-south-1": {
39-
"AMI": "ami-06c7b69755f9cccbd"
39+
"AMI": "ami-001bcfe86ab58c383"
4040
},
4141
"ap-east-1": {
42-
"AMI": "ami-0ce622c442dd13ced"
42+
"AMI": "ami-0987274ff3aee58dd"
4343
},
4444
"ap-south-1": {
45-
"AMI": "ami-0716f3eb96636ba86"
45+
"AMI": "ami-0c1bb48c8752b48b4"
4646
},
4747
"ap-northeast-1": {
48-
"AMI": "ami-01ec0de36d77714fc"
48+
"AMI": "ami-0342e78cc98ac8477"
4949
},
5050
"ap-northeast-2": {
51-
"AMI": "ami-05fe1d3337c60b150"
51+
"AMI": "ami-010a4fc4563166544"
5252
},
5353
"ap-southeast-1": {
54-
"AMI": "ami-0e99496ad3a69b5d8"
54+
"AMI": "ami-07f2f557f3ca356c5"
5555
},
5656
"ap-southeast-2": {
57-
"AMI": "ami-0ff3bbab6addc3c87"
57+
"AMI": "ami-098f34af94a528f7e"
5858
}
5959
}
6060
},
@@ -308,7 +308,7 @@
308308
"Handler": "index.lambda_handler",
309309
"Timeout": "600",
310310
"Code": {
311-
"ZipFile": "# Copyright 2023 The MathWorks Inc.\nimport http, json, os, uuid, boto3\nfrom urllib.parse import urlparse\nfrom botocore.waiter import WaiterModel as Waiter, create_waiter_with_client as create_waiter\n\nINSTANCE_ID=os.environ['EC2_INSTANCE_ID']\nPROFILE_ID=os.environ['INSTANCE_PROFILE_ID']\nREGION=os.environ['AWS_REGION']\nLOG_GROUP='https://'+REGION+'.console.aws.amazon.com/cloudwatch/home?region='+REGION+'#logsV2:log-groups/log-group/$252Faws$252Flambda$252F'+os.environ['AWS_LAMBDA_FUNCTION_NAME']\n\ndef get_waiter_cfg(operation,argument,retry_error_codes):\n acceptors = [{\"matcher\":\"path\",\"expected\":True,\"argument\":argument,\"state\":\"success\"}] + [{\"matcher\":\"error\",\"expected\":error_code,\"state\":\"retry\",\"argument\":\"Code\"} for error_code in retry_error_codes]\n cfg={\"version\":2,\"waiters\":{\"CustomWaiter\":{\"delay\":3,\"operation\":operation,\"maxAttempts\":100,\"acceptors\": acceptors}}}\n return cfg\n\ndef get_resources(stack,response):\n cfn=boto3.client('cloudformation')\n res={}\n waiter_cfg=get_waiter_cfg(\"DescribeStackResource\",\"StackResourceDetail.ResourceStatus==`CREATE_IN_PROGRESS` || StackResourceDetail.ResourceStatus==`CREATE_COMPLETE`\",[\"ValidationError\"])\n waiter=create_waiter('CustomWaiter', Waiter(waiter_cfg), cfn)\n for id in [INSTANCE_ID, PROFILE_ID]:\n try:\n waiter.wait(StackName=stack,LogicalResourceId=id)\n resource=cfn.describe_stack_resource(StackName=stack,LogicalResourceId=id)\n res[id]=resource['StackResourceDetail']['PhysicalResourceId']\n except Exception as E:\n print(E)\n response['Reason']='Failed to get information on EC2 instance or instance profile. Check the log stream under the CloudWatch log group: '+LOG_GROUP\n return res\n\ndef send_response(request,response):\n url=urlparse(request['ResponseURL'])\n body=json.dumps(response)\n https=http.client.HTTPSConnection(url.netloc)\n https.request('PUT', url.path+'?'+url.query,body)\n return response\n \ndef lambda_handler(event,context): \n response={'StackId':event['StackId'],'RequestId':event['RequestId'],'LogicalResourceId':event['LogicalResourceId'],'Status':'SUCCESS'}\n stack=str(event['StackId']).split('/')[1]\n if 'PhysicalResourceId' in event:\n response['PhysicalResourceId']=event['PhysicalResourceId']\n else:\n response['PhysicalResourceId']=str(uuid.uuid4())\n if event['RequestType'] == 'Delete':\n return send_response(event,response)\n try:\n ec2=boto3.client('ec2')\n resources=get_resources(stack,response)\n waiter_cfg=get_waiter_cfg(\"AssociateIamInstanceProfile\",\"IamInstanceProfileAssociation.State==`associated` || IamInstanceProfileAssociation.State==`associating`\",[\"InvalidParameterValue\",\"IncorrectInstanceState\"])\n waiter=create_waiter('CustomWaiter', Waiter(waiter_cfg), ec2)\n waiter.wait(IamInstanceProfile={'Name':resources[PROFILE_ID]},InstanceId=resources[INSTANCE_ID])\n response['Reason']='Attached instance profile successfully'\n print(response['Reason'])\n except Exception as E:\n print(E)\n response['Status']='FAILED'\n if 'Reason' not in response:\n response['Reason']='Failed to attach instance profile to the EC2 instance. Check the log stream under the CloudWatch log group: '+LOG_GROUP\n return send_response(event,response)"
311+
"ZipFile": "# Copyright 2023-2024 The MathWorks, Inc.\nimport http, json, os, uuid, boto3\nfrom urllib.parse import urlparse\nfrom botocore.waiter import WaiterModel as Waiter, create_waiter_with_client as create_waiter\n\nINSTANCE_ID=os.environ['EC2_INSTANCE_ID']\nPROFILE_ID=os.environ['INSTANCE_PROFILE_ID']\nREGION=os.environ['AWS_REGION']\nLOG_GROUP='https://'+REGION+'.console.aws.amazon.com/cloudwatch/home?region='+REGION+'#logsV2:log-groups/log-group/$252Faws$252Flambda$252F'+os.environ['AWS_LAMBDA_FUNCTION_NAME']\n\ndef get_waiter_cfg(operation,argument,retry_error_codes):\n acceptors = [{\"matcher\":\"path\",\"expected\":True,\"argument\":argument,\"state\":\"success\"}] + [{\"matcher\":\"error\",\"expected\":error_code,\"state\":\"retry\",\"argument\":\"Code\"} for error_code in retry_error_codes]\n cfg={\"version\":2,\"waiters\":{\"CustomWaiter\":{\"delay\":3,\"operation\":operation,\"maxAttempts\":100,\"acceptors\": acceptors}}}\n return cfg\n\ndef get_resources(stack,response):\n cfn=boto3.client('cloudformation')\n res={}\n waiter_cfg=get_waiter_cfg(\"DescribeStackResource\",\"StackResourceDetail.ResourceStatus==`CREATE_IN_PROGRESS` || StackResourceDetail.ResourceStatus==`CREATE_COMPLETE`\",[\"ValidationError\"])\n waiter=create_waiter('CustomWaiter', Waiter(waiter_cfg), cfn)\n for id in [INSTANCE_ID, PROFILE_ID]:\n try:\n waiter.wait(StackName=stack,LogicalResourceId=id)\n resource=cfn.describe_stack_resource(StackName=stack,LogicalResourceId=id)\n res[id]=resource['StackResourceDetail']['PhysicalResourceId']\n except Exception as E:\n print(E)\n response['Reason']='Failed to get information on EC2 instance or instance profile. Check the log stream under the CloudWatch log group: '+LOG_GROUP\n return res\n\ndef send_response(request,response):\n url=urlparse(request['ResponseURL'])\n body=json.dumps(response)\n https=http.client.HTTPSConnection(url.netloc)\n https.request('PUT', url.path+'?'+url.query,body)\n return response\n \ndef lambda_handler(event,context): \n response={'StackId':event['StackId'],'RequestId':event['RequestId'],'LogicalResourceId':event['LogicalResourceId'],'Status':'SUCCESS'}\n stack=str(event['StackId']).split('/')[1]\n if 'PhysicalResourceId' in event:\n response['PhysicalResourceId']=event['PhysicalResourceId']\n else:\n response['PhysicalResourceId']=str(uuid.uuid4())\n if event['RequestType'] == 'Delete':\n return send_response(event,response)\n try:\n ec2=boto3.client('ec2')\n resources=get_resources(stack,response)\n waiter_cfg=get_waiter_cfg(\"AssociateIamInstanceProfile\",\"IamInstanceProfileAssociation.State==`associated` || IamInstanceProfileAssociation.State==`associating`\",[\"InvalidParameterValue\",\"IncorrectInstanceState\"])\n waiter=create_waiter('CustomWaiter', Waiter(waiter_cfg), ec2)\n waiter.wait(IamInstanceProfile={'Name':resources[PROFILE_ID]},InstanceId=resources[INSTANCE_ID])\n response['Reason']='Attached instance profile successfully'\n print(response['Reason'])\n except Exception as E:\n print(E)\n response['Status']='FAILED'\n if 'Reason' not in response:\n response['Reason']='Failed to attach instance profile to the EC2 instance. Check the log stream under the CloudWatch log group: '+LOG_GROUP\n return send_response(event,response)"
312312
},
313313
"Environment": {
314314
"Variables": {

0 commit comments

Comments
 (0)