Quantcast
Channel: Active questions tagged amazon-ec2 - Stack Overflow
Viewing all articles
Browse latest Browse all 29543

Cloudformation stack provisioning windows ec2 instance doesn't install required installations

$
0
0

I am trying to install git and vscode on windows ec2 instance using cloudformation template executing a stack. The stack completes successfully, however when I log onto the ec2 instance I don't see git or vscode got installed. As a matter of fact the files doesn't seems download into their respective files folder. Also, im login into ec2 instance using the default Administrator account through RDP.

Below is the piece of cf template that I'm using.

Resources:
  EC2CustomInstanceSample:
    Type: 'AWS::EC2::Instance'
    Metadata:
      AWS::CloudFormation::Init:
        config:
          files:
            c:\cfn\cfn-hup.conf:
              content:
                Fn::Join:
                - ''
                - - "[main]\n"
                  - stack=
                  - Ref: AWS::StackId
                  - "\n"
                  - region=
                  - Ref: AWS::Region
                  - "\n"
            c:\cfn\hooks.d\cfn-auto-reloader.conf:
              content:
                Fn::Join:
                - ''
                - - "[cfn-auto-reloader-hook]\n"
                  - 'triggers=post.update'
                  - 'path=Resources.EC2CustomInstanceSample.Metadata.AWS::CloudFormation::Init'
                  - 'action=cfn-init.exe -v -s '
                  - Ref: AWS::StackId
                  - " -r EC2CustomInstanceSample"
                  - " --region "
                  - Ref: AWS::Region
                  - "\n"
            c:\cfn\modules\VSCodeSetup-x64-1.40.0.exe:
              sources:  https://az764295.vo.msecnd.net/stable/86405ea23e3937316009fc27c9361deee66ffbf5/VSCodeSetup-x64-1.40.0.exe
            c:\cfn\modules\Git-2.24.0.2-64-bit.exe:
              sources: https://github.com/git-for-windows/git/releases/download/v2.24.0.windows.2/Git-2.24.0.2-64-bit.exe
          commands:
            1-install-features:
              command:
                Fn::Join:
                - ''
                - - if not "None" EQU "
                  - Ref: Features
                  - "\" (servermanagercmd -install "
                  - Ref: Features
                  - " -restart)"
            2-install-vscode:
              command: powershell.exe -ExecutionPolicy RemoteSigned -Command Start-Process -FilePath C:\cfn\modules\VSCodeSetup-x64-1.40.0 -Args '/silent /install' -Verb RunAs -wait;            
            3-install-git:
              command: powershell.exe -ExecutionPolicy RemoteSigned -Command Start-Process -FilePath C:\cfn\modules\Git-2.24.0.2-64-bit -Args '/silent /install' -Verb RunAs -wait;            
          services:
            windows:
              cfn-hup:
                enabled: 'true'
                ensureRunning: 'true'
                files:
                - c:\cfn\cfn-hup.conf
                - c:\cfn\hooks.d\cfn-auto-reloader.conf
    Properties:
      InstanceType: !Ref InstanceType
      SecurityGroups:
        - !Ref InstanceSecurityGroupSample
      #KeyName: !Ref KeyName
      #KeyName: "ec2-sample"
      KeyName: "keypairsh"
      ImageId: "ami-028be67c2aa2f1ce1"
      UserData:
        Fn::Base64:
          Fn::Join:
          - ''
          - - "<script>\n"
            - 'cfn-init.exe -v -s '
            - Ref: AWS::StackId
            - " -r EC2CustomInstanceSample"
            - " --region "
            - Ref: AWS::Region
            - "\n"
            - "</script>"

Appreciate any changes or feedback on where i'm doing wrong here.


Viewing all articles
Browse latest Browse all 29543

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>