Python über UserData in Windows installierenPython

Python-Programme
Anonymous
 Python über UserData in Windows installieren

Post by Anonymous »

Meine EC2-Instanzen verwenden Windows-2019-AMI und ich möchte Python über meine Benutzerdaten installieren. Dieses Benutzerdatenformat wird von Instanzdiagnose -> Systemprotokolle auf dem EC2 nicht erkannt. Das akzeptable Format ist auch gültiges JSON: System.xml.XmlDocument
Wie korrigiere ich diesen Cloudformation-Code?
Bitte lassen Sie mich wissen, ob es eine andere Möglichkeit gibt, Python unter Windows als CHEF zu installieren

Code: Select all

    AWSTemplateFormatVersion: '2010-09-09'
Description: Windows Server 2019 EC2 with exact UserData content

Parameters:
InstanceType:
Type: String
Default: t3.medium
AllowedValues:
- t3.micro
- t3.small
- t3.medium

KeyName:
Type: AWS::EC2::KeyPair::KeyName
Description: Existing EC2 KeyPair for RDP access

WindowsAmiId:
Type: AWS::SSM::Parameter::Value
Default: /aws/service/ami-windows-latest/Windows_Server-2019-English-Full-Base

Resources:
WindowsSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Allow RDP access
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 3389
ToPort: 3389
CidrIp: 0.0.0.0/0

WindowsInstance:
Type: AWS::EC2::Instance
Properties:
InstanceType: !Ref InstanceType
KeyName: !Ref KeyName
ImageId: !Ref WindowsAmiId
SecurityGroupIds:
- !Ref WindowsSecurityGroup
UserData:
Fn::Base64: |
{
"UserData": "\n$ErrorActionPreference = \"Stop\"\nStart-Transcript -Path \"C:\\\\UserData-Install.log\"\n\ntry {\n$pythonUrl = \"https://.....\"\n $pythonInstaller = \"c:\\\\pyhton-installer.exe\"\n [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12\n Invoke-WebRequest -Uri $pythonUrl -OutFile $pythonInstaller -UseBasicParsing\n \n Start-Process -FilePath $pythonInstaller -ArgumentList '/quiet InstallAllUsers=1 PrepandPath=1' -Wait -NoNewWindow\n} catch {\n exit 1\n}finally{\n Stop-Transcript\n}"
}
Tags:
- Key: Name
Value: Windows2019-ExactUserData

Outputs:
InstanceId:
Value: !Ref WindowsInstance

PublicIP:
Value: !GetAtt WindowsInstance.PublicIp
Code-Link – https://godbolt.org/z/7E6vPMc3T
Außerdem ist das folgende Format nicht akzeptabel. Es wird ein Fehler im Systemprotokoll wie folgt ausgegeben: „FEHLER: Phase1: AWS-Benutzerdaten sind nicht leer und kein gültiges JSON: system.Xml.XmlDocument“

Code: Select all

    UserData:
Fn::Base64: |


Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post