Commit Graph
12 Commits
Author SHA1 Message Date
Mario Toffia 460aa0718e feat(cloudwatch): provision AWS::CloudWatch::Dashboard (#3231)
* feat(cloudwatch): provision AWS::CloudWatch::Dashboard

The dashboard name is the physical id, generated when the template gives none
and kept across updates. An update with the same name puts the body again and
drives the tags to the template's set, since PutDashboard leaves an existing
dashboard's tags alone. A changed name creates the new dashboard and leaves
the displaced one to the ReplacementCleanup record, which deletes it once the
update commits or restores it on rollback. The body may be written as a JSON
object in the template and is stored as the string the API takes.

The CloudWatch docs now list the dashboard and tag actions the handlers
already serve.

* fix(cloudwatch): roll back in-place dashboard updates and replace a dashboard whose explicit name is dropped

An in-place update keeps the body and tags it replaces on the resource, or
the fact that the dashboard did not exist, and a failed stack update puts
them back in full. The name mode is recorded as the Logs provisioner does, so
a template that drops an explicit DashboardName gets a generated name and a
replacement, as on AWS, while an unnamed dashboard keeps its generated name.
The Tags list is checked against the schema's cap of 50 on every provision,
since the tag operations an update reconciles through do not enforce it. The
integration test reads stack events with XmlParser.

* fix(cloudwatch): keep the dashboard rollback snapshot until the restore succeeds

A restore that throws left no snapshot behind, so the next rollback attempt
reported success without restoring anything. The snapshot is now spent only
after the body and tags are back.

* fix(cloudwatch): unwind a dashboard update that failed after it changed the body

An in-place update puts the body and then reconciles the tags. When the tag
calls failed, the exception left the dashboard carrying the new body while
CloudFormationService put the resource the stack held before the attempt back
in its place. That object never carried the snapshot taken by the attempt, so
the walker marked it restored and skipped rollbackUpdate: the stack reported a
completed rollback over a dashboard that still had the update's body, or a half
reconciled set of tags.

The mutating calls now unwind themselves through rollbackUpdate, the way
IotDomainConfigurationCfnProvisioner unwinds a replacement, and report the
resource restored. An unwind that cannot put the body back keeps the snapshot
and records the failure on the resource, so the stack ends in
UPDATE_ROLLBACK_FAILED rather than claiming the prior dashboard is intact, and
the original failure is still what the stack reports.

Tests: anInPlaceUpdateThatFailedOnItsTagsPutsTheBodyBack,
anUnwoundInPlaceUpdateIsMarkedRestored,
anUnwindThatCannotRestoreIsReportedAsARollbackFailure.

* fix(cloudwatch): record a dashboard unwind failure before joining it to the update failure

The unwind repeats the tag call the update just made, so a service that
keeps failing hands the unwind the very exception that interrupted the
update. Throwable.addSuppressed rejects a throwable suppressed under
itself, and that IllegalArgumentException escaped the unwind before the
rollback failure was recorded: the dispatcher reported "Self-suppression
not permitted" as the resource failure, no failure attribute reached the
stored resource, and the stack ended UPDATE_ROLLBACK_COMPLETE over a
dashboard whose tags were never put back.

The failure attribute is now written first and the two exceptions are
joined only when they differ, as PipesCfnProvisioner does. Two stack-level
tests drive the whole path through CloudFormationService with a spied
CloudWatchDashboardsService, the way CloudFormationPipesCleanupIntegrationTest
does: a one-off tag failure ends in UPDATE_ROLLBACK_COMPLETE with the prior
body and tags live, a persistent one in UPDATE_ROLLBACK_FAILED naming the
dashboard and carrying the unwind's reason.

Tests: anUnwindThatFailsWithTheUpdatesOwnExceptionIsStillRecorded,
anUpdateThatFailedOnItsTagsPutsTheDashboardBackAndTheStackRollsBackCleanly,
aFailedRestoreLeavesTheStackInUpdateRollbackFailedNamingTheDashboard.
2026-09-09 22:37:45 -05:00
lex00 5b7c2c4a62 feat(cloudwatch): store and serve metric stream definitions (#3214)
* feat(cloudwatch): store and serve metric stream definitions

PutMetricStream, GetMetricStream, ListMetricStreams, DeleteMetricStream,
StartMetricStreams and StopMetricStreams work over Query and JSON. A
stream is a definition with a running or stopped state, and nothing is
delivered to the Firehose delivery stream it names. The service lives in
its own metricstreams package next to dashboards and is injected into
both handlers, and the tag operations route a metric-stream ARN to it.

Ported from lex00/floci#42.

* fix(cloudwatch): validate nested metric stream members, page ListMetricStreams, keep batches atomic

StartMetricStreams and StopMetricStreams resolve every requested name
before changing any, so a batch naming a missing stream fails as a
whole. PutMetricStream now checks the nested members: a filter needs a
Namespace, an IncludeMetrics entry needs a Namespace and a MetricName,
and a statistics configuration needs non-empty IncludeMetrics and
AdditionalStatistics. ListMetricStreams pages through the shared
Pagination helper with MaxResults and NextToken over both protocols.

* fix(cloudwatch): answer an unknown name on StartMetricStreams and StopMetricStreams with InvalidParameterValue

The model declares ResourceNotFoundException on GetMetricStream alone.
Start and Stop declare InvalidParameterValue, so an unknown name in the
batch answers that, still after resolving every name before any change.
2026-09-09 00:57:17 -05:00
Franklin G. Mendoza 6a728f1b9f feat(cloudwatchlogs): add cross-account policy operations (#3089)
* feat(cloudwatchlogs): add cross-account policy operations

* fix(cloudwatchlogs): align cross-account policy contracts

* fix(cloudwatchlogs): enforce account policy quotas

* fix(cloudwatchlogs): validate field index policy scopes

* fix(cloudwatchlogs): parse field index criteria safely

* fix(cloudwatchlogs): align field index quota parsing
2026-09-05 21:08:07 -04:00
Sam Fakhreddine 4435c62848 feat(logs): add AssociateKmsKey and DisassociateKmsKey for log groups (#2584)
* feat(logs): AssociateKmsKey / DisassociateKmsKey for log groups

floci had no CloudWatch Logs KMS association at all, so LZA's
Custom::UpdateSubscriptionFilter Lambda got UnsupportedOperation, the
resource reported FAILED, AWSAccelerator-LoggingStack rolled back, and
CDK's readback surfaced the misleading "NoStack: CloudFormationStack
object does not hold a stack".

The Lambda reads logGroup.kmsKeyId from DescribeLogGroups and only calls
AssociateKmsKey when it differs from the target key ARN, so storing the
association is not enough -- DescribeLogGroups has to echo kmsKeyId back
or the association never converges and it re-associates every deploy.

- LogGroup: kmsKeyId field
- CloudWatchLogsService: associateKmsKey / disassociateKmsKey, both
  ResourceNotFoundException on an unknown group; associate rejects a
  blank kmsKeyId with InvalidParameterException
- CloudWatchLogsHandler: AssociateKmsKey / DisassociateKmsKey actions
  (name or ARN identifier), and kmsKeyId emitted by DescribeLogGroups
  only when a key is associated

(cherry picked from commit d548de18dc5c5dc8de96cb3b37a3935915be9da2)

* fix(logs): accept resourceIdentifier on Associate/DisassociateKmsKey and require an identifier

The ARN alternative for these two operations is resourceIdentifier on the
wire (unlike the query operations' logGroupIdentifier), so SDK requests
identifying the group by ARN previously failed with ResourceNotFoundException.
A request with neither identifier now returns InvalidParameterException
instead of resolving a null group name. Both actions documented in the
cloudwatch supported-actions table.

* fix(logs): reject KMS requests naming both logGroupName and resourceIdentifier

AWS models the two identifiers as mutually exclusive — exactly one is
required. Supplying both previously succeeded against the named group
while silently ignoring the ARN target.

* fix(logs): enforce the modeled input constraints on the pre-existing operations

logEvents (1-10000 on PutLogEvents), logStreamNames (1-100 on
FilterLogEvents) and the Random/ByLogStream distribution enum on
PutSubscriptionFilter now answer the modeled InvalidParameterException
instead of being accepted verbatim. Included here because this PR
already hardens the same handler; found by a model-grounded constraint
sweep.

* fix(logs): treat a present-but-blank KMS target identifier as present

A blank logGroupName beside a valid resourceIdentifier slipped past the
exclusivity check as "absent" and the mutation proceeded on the valid
field. Presence is now membership (non-null), and a blank chosen
identifier is rejected outright — the model pins both to min length 1.

* fix(logs): store kmsKeyId on CreateLogGroup, reject query-result identifiers, and treat null lists as absent

CreateLogGroup modeled kmsKeyId but the handler never read it, so an
encrypted-at-creation request was accepted, stored nowhere, and absent
from DescribeLogGroups. Both AssociateKmsKey and DisassociateKmsKey
resolve resourceIdentifier through extractLogGroupNameFromArn, which
only recognizes the :log-group: form; the modeled :query-result: form
(account-wide GetQueryResults encryption, a separate feature) fell
through unchanged and became a misleading ResourceNotFoundException
naming a log group the caller never specified. FilterLogEvents also
used request.has("logStreamNames"), which is true for an explicit
JSON null, tripping the min-1 bound the same way an empty array does;
AWS treats an explicit null on an optional member as absent.

Fixes all three: plumb kmsKeyId through a new createLogGroup overload
and store it when non-blank; recognize and reject the query-result
resourceIdentifier form as unsupported instead of mangling it;  switch
to hasNonNull for logStreamNames, matching the idiom already used in
resolveKmsTargetLogGroupName. Also fixes requireListSize's
fully-qualified JsonNode parameter and a stray blank line.
2026-08-27 10:50:05 -04:00
Aniket Shukla 859db2f352 feat(cloudwatch-logs): add resource policy actions (#2574) 2026-08-25 23:41:09 -05:00
TiM 112602fc6e fix(cloudwatch): page FilterLogEvents forward with a usable nextToken (#2354)
FilterLogEvents returned UUID.randomUUID() as its nextToken and had no
nextToken parameter to accept one back, so a response could advertise more
results while giving a client no way to reach them. Truncation compounded it:
the time and pattern filters ran before .limit(maxEvents) over an
ascending-sorted list, so an over-cap query kept the oldest matches and the
newest were unreachable. The canonical use of this action is finding the error
that just happened across a group, which is exactly the event most likely to be
dropped.

Accept a nextToken and make it an f/<index> offset into the matched set,
reusing the parser GetLogEvents already validates its tokens with so a
malformed, negative or overflowing token raises InvalidParameterException here
too. The offset indexes matches rather than stored events, so a request
narrowed by pattern, time range or stream names pages through only what it
matched.

Emit the token only when a further page exists, unlike GetLogEvents which
echoes its forward token back. The two AWS actions signal exhaustion
differently: FilterLogEvents documents an absent nextToken as "pagination is
finished", and its SDK paginators keep requesting while the token is present
with no same-token guard, so echoing a final token would never terminate. Also
refuse to emit a cursor that cannot advance, which a max-events cap configured
to zero would otherwise produce, and compute the page end by subtracting from
the total so a cap near Integer.MAX_VALUE cannot overflow the index negative.

startFromHead is still unsupported, so results run oldest first.
2026-08-17 13:25:47 -04:00
Saatvik Arya 4215006fe2 feat(logs): support log group deletion protection (#2256)
* fix(logs): accept log group deletion protection lifecycle

* feat(logs): support log group deletion protection
2026-08-12 22:39:39 -04:00
soreavis f1c81977ec fix(cloudwatch): warn on unsupported Logs Insights filter operators (#2170)
parseFilter scans for the leftmost '!=', '==' or '=' outside a quoted
value, so the '=' inside '>=', '<=' and '=~' won. For '>=' and '<=' the
comparison character was absorbed into the field name ("@message >"),
which resolves to null for every row, and passesFilters treats null as
non-matching; for '=~' the value became the literal "~ /ERROR/". Either
way the query came back with no rows and no warning, because as far as
parseFilter was concerned it had found a valid operator.

Stop the scan when a position starts one of those three operators, so
control reaches the "Ignoring unsupported Logs Insights filter" warning
that '<', '>', 'like', 'not like' and 'in' already hit, and the stage is
dropped instead. Quote tracking is untouched, so a '>=' inside a quoted
value is still just part of the value.

The docs table describing how unsupported syntax degrades had the same
two cases inverted: '=~' listed as warn-and-drop when it mis-parsed, and
bare '<' / '>' as silent-zero-rows when they already warned. Folded into
the one row that now matches the code, and the compound and/or mis-parse
this change does not fix got its own row instead of staying implied.

Refs #2042
2026-08-12 10:52:24 -04:00
武田隆志 86134e8c7f docs(cloudwatch): document Logs Insights subset and missing Logs actions (#2044)
docs/services/cloudwatch.md listed 14 of the 24 actions that
CloudWatchLogsHandler dispatches. The handler is on the deferred_handlers
allowlist in tools/docs/services.yaml, so the table is maintained by hand and
had drifted as actions were added.

Most notably Logs Insights (StartQuery / GetQueryResults / StopQuery, added in
1.5.31) was undocumented, leaving no way to discover which parts of the query
language are implemented.

Add the 10 missing actions and a Logs Insights section covering the supported
commands, the field syntax, and how each kind of unsupported input degrades:
a dropped filter stage returns every row, a >= or <= comparison is mis-parsed
into a field name and returns none, a missing projected field becomes an empty
string, and an unrecognised sort direction falls back to ascending.

Also note the PutSubscriptionFilter and GetDataProtectionPolicy
simplifications, document
FLOCI_SERVICES_CLOUDWATCHLOGS_QUERY_COMPLETION_DELAY_MS in both the service
page and the central environment-variable list, correct the
MAX_EVENTS_PER_QUERY description, and add a start-query example.
2026-07-29 23:38:24 -05:00
Hector Ventura 9e35046647 Docs/enviroment instead yml (#764)
* docs: moving all config to env instead of yml
* docs: sync with main and new features
* docs: reverting docker-compose.yml
2026-05-10 11:53:31 -05:00
TiM a32b7f1f3b docs: comprehensive audit sweep + CHANGELOG backfill (1.1.0-1.5.2) (#326)
CHANGELOG.md was empty for the 1.1.0-1.5.2 release cycle and service docs
had drifted from code behaviour. This sweep reconciles docs against the
current codebase on upstream/main.

- Backfill CHANGELOG.md for 1.1.0 through 1.5.2 from git history
- Correct exact operation counts in docs/services/index.md: S3 (~30 -> 58),
  Lambda (~25 -> 30), API Gateway v1 (~24 -> 62). Counts now come from the
  actual dispatch handlers rather than @Path annotation counts.
- Rewrite README "Supported Services" table to drop per-service op counts
  (they drift too fast); point readers at docs/services/index.md
- Update 24 service docs for accuracy, add "Not Implemented" sections
  where relevant (s3.md, lambda.md, api-gateway.md)
- Refresh configuration and getting-started docs
- Add EventBridge Scheduler and AppConfig to mkdocs nav
- Add AppConfig / AppConfigData rows to README and services index
  following the 1.5.2 upstream release
2026-04-10 10:52:34 -05:00
Hector Ventura 61433f59ab firt commit 2026-03-15 17:43:56 -05:00