如何在AWS中使用云形成来安装Java?

时间:2018-07-10 09:23:52

标签: java amazon-web-services

有人可以让我知道我在做什么错吗?

{
    "Description": "AWS CloudFormation Sample Template EC2InstanceWithSecurityGroupSampleAndEBS",
    "Resources": {
        "Ec2Instance": {
            "Metadata": {
            },
            "Type": "AWS::EC2::Instance",
            "Properties": {
                "KeyName": "Ankit_Test",
                "ImageId": "ami-9f086de0",
                "InstanceType": "t1.micro",
                "NetworkInterfaces": [{
                    "GroupSet": ["sg-d59ddbb0"],
                    "AssociatePublicIpAddress": "true",
                    "DeviceIndex": "0",
                    "DeleteOnTermination": "true",
                    "SubnetId": "subnet-09977c7f"
                }],
                "BlockDeviceMappings": [{
                    "DeviceName": "/dev/sdm",
                    "Ebs": {
                        "VolumeType": "io1",
                        "Iops": 300,
                        "DeleteOnTermination": true,
                        "VolumeSize": 100
                    }
                }],
                "UserData": {
                    "Fn::Base64": {
                        "Fn::Join": [
                            "", [
                                "#!/bin/bash\n",
                                "sudo apt-get update && sudo apt-get install && install wget https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz\n",
                                "/usr/local / bin / cfn - init\n",
                                "/opt/aws/bin/cfn-init -v \n",
                                "sudo mkfs -t ext4 /dev/xvdm\n",
                                "sudo mkdir /mntfirm\n",
                                "sudo mount /dev/xvdm /mntfirm\n",
                                "cd /mntfirm"
                                "wget http://download.jboss.org/jbossas/7.1/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final.zip\n",
                                "wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/${JAVA_VERSION}-b14/jdk-${JAVA_VERSION}-linux-x64.tar.gz\n",
                                "tar -zxvf jdk-${JAVA_VERSION}-linux-x64.tar.gz -C /opt\n",
                                "rm jdk-${JAVA_VERSION}-linux-x64.tar.gz\n",
                                "cd /opt/jdk1.7.0_${JAVA_MINOR}\n",
                                "update-alternatives --install /usr/bin/java java /opt/java/jdk1.8.${JAVA_MINOR}/bin/java 100\n",
                                "sudo alternatives --set java /opt/java/jdk1.7.0/bin/java\n",
                                "export JAVA_HOME=/opt/java/jdk1.8.${JAVA_MINOR}\n",
                                "export JRE_HOME=/opt/java/jdk1.8.${JAVA_MINOR}/jre\n",
                                "rm /opt/jdk\n",
                                "ln -s /opt/jdk1.8.0_${JAVA_MINOR} /opt/jdk\n"
                                "\n"
                            ]
                        ]
                    }
                }
            }
        }
    }
}

0 个答案:

没有答案