Skip to content

Comments

feat(ec2): implement EC2 service with basic instance operations#205

Merged
sivchari merged 5 commits intomainfrom
feat/ec2-basic-implementation
Feb 6, 2026
Merged

feat(ec2): implement EC2 service with basic instance operations#205
sivchari merged 5 commits intomainfrom
feat/ec2-basic-implementation

Conversation

@sivchari
Copy link
Owner

@sivchari sivchari commented Feb 6, 2026

Overview

Implements EC2 service with 12 basic operations for instance management, security groups, and key pairs.

Changes

EC2 Service Implementation

  • Instance operations: RunInstances, TerminateInstances, DescribeInstances, StartInstances, StopInstances
  • Security groups: CreateSecurityGroup, DeleteSecurityGroup, AuthorizeSecurityGroupIngress, AuthorizeSecurityGroupEgress
  • Key pairs: CreateKeyPair, DeleteKeyPair, DescribeKeyPairs

Query Protocol Enhancement

  • Add Actions() method to QueryProtocolService interface
  • Implement action-based routing in QueryProtocolDispatcher
  • Enable multiple Query protocol services (EC2, SNS) to coexist on POST /

Files Changed

  • internal/service/ec2/: New EC2 service implementation
    • types.go: Request/response types and XML structures
    • storage.go: In-memory storage with RSA key pair generation
    • handlers.go: Operation handlers for all 12 APIs
    • service.go: Service registration with QueryProtocolService
  • internal/server/awsquery.go: Action-based routing for Query protocol
  • internal/server/server.go: Register actions during service registration
  • internal/service/interface.go: Add Actions() to QueryProtocolService
  • internal/service/sns/service.go: Implement Actions() method
  • test/integration/ec2_test.go: Integration tests with AWS SDK v2

Testing

  • Integration tests added for all operations
  • Build passes
  • go vet passes
  • CI integration tests (pending)

Checklist

  • Code follows project guidelines (CLAUDE.md)
  • All commit messages in English
  • Single responsibility (1 Issue = 1 PR)
  • AWS SDK v2 compatible
  • Query protocol properly handled
  • CI passes

Closes #13

Implement EC2 service with support for:
- RunInstances, TerminateInstances, DescribeInstances
- StartInstances, StopInstances
- CreateSecurityGroup, DeleteSecurityGroup
- AuthorizeSecurityGroupIngress, AuthorizeSecurityGroupEgress
- CreateKeyPair, DeleteKeyPair, DescribeKeyPairs

Also update QueryProtocolService interface to support action-based
routing, allowing multiple Query protocol services (EC2, SNS) to
coexist on the same endpoint.

Closes #13
- Add EC2 tagliatelle exclusion in golangci.yaml for PascalCase JSON tags
- Add package comment to handlers.go
- Rename IpPermission to IPPermission (var-naming)
- Rename EC2Error to Error (exported stutter)
- Fix staticcheck S1016: use type conversion for XMLGroupIdentifier
- Fix wsl: add blank line before range statement
- Split DescribeKeyPairs into helper functions to fix funlen
EC2 SDK sends Action parameter in POST body (form-urlencoded), not in
URL query string. The QueryProtocolDispatcher parses the body and sets
X-Amz-Target header with the action name. Update DispatchAction to
read the action from this header first, with URL query fallback.
- Convert form values to proper JSON types (int, bool) for unmarshaling
- Use GroupDescription field name to match AWS SDK parameter name
EC2 Query protocol sends array parameters like InstanceId.1, InstanceId.2.
Convert these to JSON arrays with plural name (InstanceId -> InstanceIds).
@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

📊 Integration Test Coverage Report

Total Coverage: 64.6%

@sivchari sivchari marked this pull request as ready for review February 6, 2026 13:06
@sivchari sivchari merged commit 9144576 into main Feb 6, 2026
3 checks passed
@sivchari sivchari deleted the feat/ec2-basic-implementation branch February 6, 2026 13:06
@github-actions github-actions bot mentioned this pull request Feb 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EC2: Service implementation

1 participant