Skip to content

Commit

Permalink
Fix up path to S-2 metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgleith committed Feb 16, 2021
1 parent eb5cabb commit d9151ce
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 49 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ init:
# 3. Add a product definition for Sentinel-2
product:
docker-compose exec jupyter \
datacube product add https://raw.githubusercontent.com/digitalearthafrica/config/master/products/esa_s2_l2a.yaml
datacube product add https://raw.githubusercontent.com/digitalearthafrica/config/master/products/esa_s2_l2a.odc-product.yaml

# 4. Index some data (just an example, you can change the extents)
index:
Expand Down
106 changes: 58 additions & 48 deletions cube-in-a-box-cloudformation.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
AWSTemplateFormatVersion: '2010-09-09'
AWSTemplateFormatVersion: "2010-09-09"
Metadata:
License: Apache-2.0
Description: 'Open Data Cube template with EC2 instance and RDS.'
Description: "Open Data Cube template with EC2 instance and RDS."
Parameters:
KeyName:
Description: Name of an existing EC2 KeyPair to enable SSH access to the instance
Expand All @@ -11,29 +11,39 @@ Parameters:
Description: WebServer EC2 instance type
Type: String
Default: t2.small
AllowedValues: [
t2.small, t2.medium, t2.large,
m1.large, m1.xlarge, m2.xlarge,
c4.large, c4.xlarge, c4.2xlarge,
g2.8xlarge, r3.large, r3.xlarge]
AllowedValues:
[
t2.small,
t2.medium,
t2.large,
m1.large,
m1.xlarge,
m2.xlarge,
c4.large,
c4.xlarge,
c4.2xlarge,
g2.8xlarge,
r3.large,
r3.xlarge,
]
ConstraintDescription: must be a valid EC2 instance type.
ExtentToIndex:
Description: An extent to index for use in the Cube in a Box
Type: String
Default: '25,20,35,30'
Default: "25,20,35,30"
SecretPassword:
Description: Password to open up the Jupyter notebook
Type: String
Default: 'secretpassword'
Default: "secretpassword"
EC2InstanceName:
Description: The name of the Cube in a Box EC2 instance
Type: String
Default: 'Cube-in-a-Box'
Default: "Cube-in-a-Box"
SSHLocation:
Description: The IP address range that can be used to access the Cube in a Box
Type: String
MinLength: '9'
MaxLength: '18'
MinLength: "9"
MaxLength: "18"
Default: 0.0.0.0/0
AllowedPattern: (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/(\d{1,2})
ConstraintDescription: must be a valid IP CIDR range of the form x.x.x.x/x.
Expand All @@ -52,15 +62,15 @@ Resources:
EC2Instance:
Type: AWS::EC2::Instance
Properties:
InstanceType: !Ref 'InstanceType'
SecurityGroups: [!Ref 'InstanceSecurityGroup']
KeyName: !Ref 'KeyName'
InstanceType: !Ref "InstanceType"
SecurityGroups: [!Ref "InstanceSecurityGroup"]
KeyName: !Ref "KeyName"
ImageId: !FindInMap [RegionMap, !Ref "AWS::Region", HVM64]
IamInstanceProfile: !Ref ODCInstanceProfile
BlockDeviceMappings:
- DeviceName: /dev/sda1
Ebs:
VolumeSize: 40
VolumeSize: 50
UserData:
Fn::Base64: !Sub |
#!/bin/bash -ex
Expand Down Expand Up @@ -89,69 +99,69 @@ Resources:
# Initialise and load a product, and then some data
# Note to future self, we can't use make here because of TTY interactivity (the -T flag)
sudo docker-compose -f docker-compose.yml -f docker-compose-prod.yml exec -T jupyter datacube -v system init
sudo docker-compose -f docker-compose.yml -f docker-compose-prod.yml exec -T jupyter datacube product add https://raw.githubusercontent.com/digitalearthafrica/config/master/products/esa_s2_l2a.yaml
sudo docker-compose -f docker-compose.yml -f docker-compose-prod.yml exec -T jupyter datacube product add https://raw.githubusercontent.com/digitalearthafrica/config/master/products/esa_s2_l2a.odc-product.yaml
sudo docker-compose -f docker-compose.yml -f docker-compose-prod.yml exec -T jupyter bash -c "stac-to-dc --bbox=${ExtentToIndex} --collections='sentinel-s2-l2a-cogs' --datetime='2020-01-01/2020-03-31' s2_l2a"
Tags:
- Key: "Name"
Value: !Ref 'EC2InstanceName'
- Key: "Name"
Value: !Ref "EC2InstanceName"

InstanceSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Enable access
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: '22'
ToPort: '22'
CidrIp: !Ref 'SSHLocation'
- IpProtocol: tcp
FromPort: '80'
ToPort: '80'
CidrIp: !Ref 'SSHLocation'
- IpProtocol: tcp
FromPort: '8888'
ToPort: '8888'
CidrIp: !Ref 'SSHLocation'
- IpProtocol: tcp
FromPort: "22"
ToPort: "22"
CidrIp: !Ref "SSHLocation"
- IpProtocol: tcp
FromPort: "80"
ToPort: "80"
CidrIp: !Ref "SSHLocation"
- IpProtocol: tcp
FromPort: "8888"
ToPort: "8888"
CidrIp: !Ref "SSHLocation"

ODCRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
Service:
- ec2.amazonaws.com
Action:
- sts:AssumeRole
- Effect: Allow
Principal:
Service:
- ec2.amazonaws.com
Action:
- sts:AssumeRole
Path: "/"
RolePolicies:
Type: AWS::IAM::Policy
Properties:
PolicyName: odc-policy
PolicyDocument:
Version: '2012-10-17'
Version: "2012-10-17"
Statement:
- Effect: Allow
Action: ["S3:ListBucket"]
Resource: ["arn:aws:s3:::landsat-pds"]
- Effect: Allow
Action: ["S3:GetObject"]
Resource: ["arn:aws:s3:::landsat-pds/*"]
- Effect: Allow
Action: ["S3:ListBucket"]
Resource: ["arn:aws:s3:::landsat-pds"]
- Effect: Allow
Action: ["S3:GetObject"]
Resource: ["arn:aws:s3:::landsat-pds/*"]
Roles:
- !Ref ODCRole
- !Ref ODCRole
ODCInstanceProfile:
Type: AWS::IAM::InstanceProfile
Properties:
Path: "/"
Roles:
- !Ref ODCRole
- !Ref ODCRole

Outputs:
InstanceId:
Description: InstanceId of the newly created EC2 instance
Value: !Ref 'EC2Instance'
Value: !Ref "EC2Instance"
AZ:
Description: Availability Zone of the newly created EC2 instance
Value: !GetAtt [EC2Instance, AvailabilityZone]
Expand Down

0 comments on commit d9151ce

Please sign in to comment.