Skip to content

Commit 7ce7ccd

Browse files
authored
PE-7997 : fix condition added for config.yaml (#532)
Updated README
1 parent 58bd9a7 commit 7ce7ccd

File tree

3 files changed

+100
-30
lines changed

3 files changed

+100
-30
lines changed

Earthfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,7 @@ cloud-image:
948948
WORKDIR /workdir
949949

950950
# Create a default config.yaml if it doesn't exist. This is needed to avoid auroraboot from creating its own default cloud-config.
951-
RUN [ ! -f /config.yaml ] && echo "#cloud-config" > /config.yaml
951+
RUN if [ ! -f /config.yaml ]; then echo "#cloud-config" > /config.yaml; fi
952952
WITH DOCKER \
953953
--pull $AURORABOOT_IMAGE \
954954
--load index.docker.io/library/palette-installer-image:latest=(+iso-image --IS_CLOUD_IMAGE=true)

README.md

Lines changed: 89 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -268,29 +268,99 @@ To build just the installer image
268268
./earthly.sh +iso --ARCH=amd64
269269
```
270270

271-
To build public cloud images(currently only aws is supported)
272-
aws cloud credentials should be passed in the `.secret` file on the repo dir
273-
example:
274-
```shell
275-
/workspace/spectrocloud/CanvOS$ cat .secret
276-
AWS_PROFILE=""
277-
AWS_ACCESS_KEY_ID="xxxxxx"
278-
AWS_SECRET_ACCESS_KEY="xxxxxxx"
279-
```
280-
Also region and bucket details need to be passed in .arg file
281-
```shell
282-
#aws cloud
283-
REGION="us-east-1"
284-
S3_BUCKET="test-bkp"
285-
S3_KEY=""
286-
```
287-
user-data should be kept under `cloud-images/config/user-data.yaml`
271+
### Building AWS Cloud Images
272+
273+
CanvOS can build Amazon Machine Images (AMIs) for AWS EC2 deployment. The build process converts the raw disk image into an AMI that can be launched directly in AWS.
274+
275+
#### Prerequisites
276+
277+
1. **AWS Credentials**: Configure AWS credentials in the `.secret` file in the repo directory.
278+
279+
**Option 1: Using AWS Profile (Recommended)**
280+
```shell
281+
AWS_PROFILE="production"
282+
```
283+
284+
**Option 2: Using Access Keys**
285+
```shell
286+
AWS_PROFILE=""
287+
AWS_ACCESS_KEY_ID="ACCESS_EXAMPLE_KEY"
288+
AWS_SECRET_ACCESS_KEY="SECRET_EXAMPLE_KEY"
289+
```
290+
291+
2. **AWS Configuration**: Add the following to your `.arg` file:
292+
```shell
293+
# AWS Cloud Image Configuration
294+
REGION="us-east-1"
295+
S3_BUCKET="my-canvos-images"
296+
S3_KEY="" # Optional: defaults to raw file name if not set
297+
```
298+
299+
3. **User Data Configuration**: Create or update `user-data` in the CanvOS root directory with your cloud-init configuration:
300+
```yaml
301+
#cloud-config
302+
install:
303+
device: /dev/sda
304+
reboot: true
305+
poweroff: false
306+
stylus:
307+
debug: true
308+
site:
309+
paletteEndpoint: xxxx.spectrocloud.com
310+
autoRegister: true
311+
edgeHostToken: xxxxxxxxxxx
312+
insecureSkipVerify: false
313+
```
314+
315+
#### Building the AWS Cloud Image
316+
317+
Run the following command to build the AWS cloud image:
288318
289-
To build AWS cloud image:
290319
```shell
291-
./earthly.sh -P +aws-cloud-image --ARCH=amd64
320+
earthly -P +aws-cloud-image --ARCH=amd64
292321
```
293322

323+
The `-P` flag enables privileged mode (required for Docker-in-Docker operations).
324+
325+
#### Build Process
326+
327+
The AWS cloud image build consists of two steps:
328+
329+
1. **Step 1**: Builds the cloud image (raw disk image) using auroraboot
330+
- Creates a raw disk image from the installer image
331+
- Includes user-data configuration
332+
- Supports content bundles and cluster configs
333+
334+
2. **Step 2**: Converts raw image to AMI
335+
- Uploads raw image to S3 bucket
336+
- Imports snapshot from S3
337+
- Registers AMI in EC2
338+
- Returns AMI ID upon completion
339+
340+
#### Output
341+
342+
After a successful build, the AMI will be registered in your AWS account. The build output will display:
343+
- AMI ID (e.g., `ami-0123456789abcdef0`)
344+
- AMI Name (based on `S3_KEY` or auto-generated)
345+
- Snapshot ID (created during import)
346+
347+
#### IAM Permissions Required
348+
349+
The AWS credentials must have the following permissions:
350+
- `s3:PutObject`, `s3:GetObject`, `s3:ListBucket` on the S3 bucket
351+
- `ec2:ImportSnapshot`, `ec2:DescribeImportSnapshotTasks`
352+
- `ec2:DescribeSnapshots`, `ec2:RegisterImage`
353+
- `ec2:DescribeImages`, `ec2:CreateTags`
354+
355+
#### Troubleshooting
356+
357+
- **"RAW file not found"**: Ensure `+cloud-image` target completed successfully
358+
- **"Missing required configuration variables"**: Verify `REGION` and `S3_BUCKET` are set in `.arg` file
359+
- **"AWS credentials not found"**: Check `.secret` file has valid AWS credentials
360+
- **"Snapshot import failed"**: Verify IAM permissions and S3 bucket accessibility
361+
362+
For more detailed information, see [AWS Cloud Image Design Document](docs/aws-cloud-image-design.md).
363+
294364
To build the provider images
295365

296366
```shell

docs/aws-cloud-image-design.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ AWS_SECRET_ACCESS_KEY=<secret-key>
174174

175175
#### Dependencies
176176
- `+cloud-image` target must be executed first (provides raw image)
177-
- `cloud-images/config/user-data.yaml` must exist (used by cloud-image)
177+
- `user-data` must exist in the CanvOS root directory (used by cloud-image)
178178

179179
### 4.2 Outputs
180180

@@ -223,7 +223,7 @@ AWS_SECRET_ACCESS_KEY="wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
223223

224224
### 5.3 user-data.yaml Configuration
225225

226-
Located at: `cloud-images/config/user-data.yaml`
226+
Located at: `user-data` (in the CanvOS root directory)
227227

228228
```yaml
229229
#cloud-config
@@ -378,7 +378,7 @@ The AWS credentials must have the following permissions:
378378

379379
```bash
380380
# Build AWS cloud image
381-
./earthly.sh -P +aws-cloud-image \
381+
earthly -P +aws-cloud-image \
382382
--REGION=us-east-1 \
383383
--S3_BUCKET=my-canvos-images \
384384
--S3_KEY=canvos-image.raw \
@@ -393,7 +393,7 @@ cat > .secret <<EOF
393393
AWS_PROFILE=production
394394
EOF
395395
396-
./earthly.sh -P +aws-cloud-image \
396+
earthly -P +aws-cloud-image \
397397
--REGION=us-east-1 \
398398
--S3_BUCKET=my-canvos-images \
399399
--ARCH=amd64
@@ -408,7 +408,7 @@ AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
408408
AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
409409
EOF
410410
411-
./earthly.sh -P +aws-cloud-image \
411+
earthly -P +aws-cloud-image \
412412
--REGION=us-east-1 \
413413
--S3_BUCKET=my-canvos-images \
414414
--ARCH=amd64
@@ -418,13 +418,13 @@ EOF
418418

419419
```bash
420420
# Step 1: Build installer image
421-
./earthly.sh +iso-image --ARCH=amd64
421+
earthly +iso-image --ARCH=amd64
422422
423423
# Step 2: Build cloud image (creates raw file)
424-
./earthly.sh +cloud-image --ARCH=amd64
424+
earthly +cloud-image --ARCH=amd64
425425
426426
# Step 3: Convert to AMI
427-
./earthly.sh -P +aws-cloud-image \
427+
earthly -P +aws-cloud-image \
428428
--REGION=us-east-1 \
429429
--S3_BUCKET=my-canvos-images \
430430
--ARCH=amd64
@@ -526,7 +526,7 @@ EOF
526526
**Cause**: `+cloud-image` target didn't produce a raw file
527527
**Solution**:
528528
- Verify `+cloud-image` target completed successfully
529-
- Check that `cloud-images/config/user-data.yaml` exists
529+
- Check that `user-data` exists in the CanvOS root directory
530530
- Review auroraboot logs in build output
531531

532532
#### Issue: "Missing required configuration variables"
@@ -604,7 +604,7 @@ Enable debug output by checking:
604604

605605
- `Earthfile`: Main build definition
606606
- `cloud-images/scripts/create-raw-to-ami.sh`: Conversion script
607-
- `cloud-images/config/user-data.yaml`: Cloud-init configuration
607+
- `user-data`: Cloud-init configuration (in the CanvOS root directory)
608608
- `.arg.template`: Argument template file
609609
- `README.md`: Project documentation
610610

0 commit comments

Comments
 (0)