--- AWSTemplateFormatVersion: 2010-09-09 Description: Launches one Amazon EC2 Linux instance Metadata: AWS::CloudFormation::Interface: ParameterGroups: - Label: default: Amazon EC2 Linux Instances Parameters: - LinuxDistribution - InstanceType - SubnetId - SecurityGroupId - KeyName - FileSystemId ParameterLabels: FileSystemId: default: File system ID KeyName: default: EC2 key pair InstanceType: default: Instance type LinuxDistribution: default: Linux distribution SecurityGroupId: default: Security group SubnetId: default: Subnet Parameters: FileSystemId: AllowedPattern: ^(fs-)([a-z0-9]{17})$ Description: Amazon FSx file system ID Type: String KeyName: Description: Select the EC2 key pair Type: AWS::EC2::KeyPair::KeyName InstanceType: AllowedValues: - c5n.9xlarge - c5n.18xlarge Default: c5n.9xlarge Description: Select the instance type Type: String LinuxDistribution: AllowedValues: - "Amazon Linux 2 (x86_64)" Default: "Amazon Linux 2 (x86_64)" Description: Select the Linux distribution Type: String SecurityGroupId: Description: Select the security group Type: AWS::EC2::SecurityGroup::Id SubnetId: Description: Select the subnet Type: AWS::EC2::Subnet::Id Resources: Instance0: Type: AWS::EC2::Instance Properties: ImageId: !GetAtt AmiInfo.Id Monitoring: true InstanceType: !Ref InstanceType KeyName: !Ref KeyName SecurityGroupIds: - !Ref SecurityGroupId SubnetId: !Ref SubnetId Tags: - Key: Name Value: "Linux Instance 0" UserData: Fn::Base64: !Sub | #cloud-config repo_update: true repo_upgrade: all runcmd: # update - yum update -y # install tools - amazon-linux-extras install -y epel lustre2.10 - yum groupinstall -y "Development Tools" - yum install -y parallel ioping tree nload git libaio-devel openmpi openmpi-devel # install fio - git clone git://git.kernel.dk/fio.git - cd fio - ./configure - make - make install - cd # install ior - git clone https://github.com/hpc/ior.git - export PATH=$PATH:/usr/lib64/openmpi/bin - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib64/openmpi/lib/ - cd ior - ./bootstrap - ./configure - make - sudo cp src/ior /usr/local/bin - cd # mount fsx lustre - _availability_zone=$(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone) - _region=${!_availability_zone:0:-1} - _mount_point=/mnt/fsx - mkdir -p ${!_mount_point} - echo "${FileSystemId}.fsx.${!_region}.amazonaws.com@tcp:/fsx ${!_mount_point} lustre defaults,_netdev 0 0" >> /etc/fstab - mount -a - chown ec2-user:ec2-user /mnt/fsx - reboot AmiInfoFunction: Type: AWS::Lambda::Function Properties: Code: S3Bucket: !Sub solution-references-${AWS::Region} S3Key: fsx/amilookup-lin.zip Handler: amilookup-lin.handler Runtime: nodejs12.x Timeout: 30 Role: !GetAtt LambdaExecutionRole.Arn AmiInfo: Type: Custom::AmiInfo Properties: ServiceToken: !GetAtt AmiInfoFunction.Arn Region: !Ref 'AWS::Region' OSName: !Ref LinuxDistribution LambdaExecutionRole: Type: AWS::IAM::Role Properties: AssumeRolePolicyDocument: Version: '2012-10-17' Statement: - Effect: Allow Principal: Service: - lambda.amazonaws.com Action: - sts:AssumeRole ManagedPolicyArns: - 'arn:aws:iam::aws:policy/AWSLambdaExecute' Path: "/" Policies: - PolicyName: root PolicyDocument: Version: '2012-10-17' Statement: - Effect: Allow Action: - ec2:DescribeImages Resource: "*" Outputs: Instance0: Description: Amazon EC2 instance ID Value: !Ref Instance0 InstanceDnsName: Description: Amazon EC2 instance public DNS name Value: !GetAtt Instance0.PublicDnsName LinuxDistribution: Description: Amazon EC2 instance Linux distribution Value: !Ref LinuxDistribution InstanceAmi: Description: Amazon EC2 instance AMI ID Value: !GetAtt AmiInfo.Id