aws-cloudformation / aws-cloudformation/cloudformation-coverage-roadmap

AWS::Scheduler::ScheduleGroup - Cannot create: Unable to retrieve Arn attribute for AWS::Scheduler::Schedule

Open
#1,726 6 comments 8 reactions 0 assignees View on GitHub
bug
Dominant language
No language data
Stars
1.1k
Forks
62
PR merge metrics
No merged PRs in 30d

Description

### Name of the resource

AWS::Scheduler::ScheduleGroup

### Resource Name

AWS::Scheduler::ScheduleGroup

### Issue Description

Cannot create a stack which contains a [AWS::Scheduler::ScheduleGroup](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler-schedulegroup.html) and a [AWS::Scheduler::Schedule](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler-schedule.html).

### Expected Behavior

Stack creates successfully.

### Observed Behavior

Stack creation fails with the following error message on stack-level..

```
Unable to retrieve Arn attribute for AWS::Scheduler::Schedule, with error message Resource of type 'AWS::Scheduler::Schedule' with identifier 'SchedulerStack-MyCfnSchedule-XXXXXXX' was not found.. Rollback requested by user.
```

### Test Cases

CDK

```
from aws_cdk import (
# Duration,
Stack, CfnOutput,
aws_scheduler as scheduler, aws_lambda as lambda_, RemovalPolicy,
)
from aws_cdk.aws_iam import ManagedPolicy, Role, ServicePrincipal
from aws_cdk.aws_lambda import Runtime, Code
from aws_cdk.aws_scheduler import CfnSchedule
from constructs import Construct

class SchedulerStack(Stack):

def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)

managed_policy_arn = \
ManagedPolicy.from_aws_managed_policy_name('AmazonEventBridgeSchedulerFullAccess')

schedule_role = Role(self, "Role",
assumed_by=ServicePrincipal("scheduler.amazonaws.com"),
# custom description if desired
description="This is a custom role...",
managed_policies=[managed_policy_arn],
)
schedule_role.apply_removal_policy(RemovalPolicy.DESTROY)

fn = lambda_.Function(self, "lambda_function",
runtime=Runtime.NODEJS_18_X,
handler="index.handler",
code=Code.from_inline('exports.handler = handler.toString() //'))

schedule_group = scheduler.CfnScheduleGroup(self, "MyScheduleGroup",
name="GroupOfSchedules", )

CfnOutput(self, 'ScheduleGroupName',
description='The Name attribute of the schedule group.',
value=str(schedule_group.name)
)
CfnOutput(self, 'ScheduleGroupArn',
description='The ARN of the schedule group.',
value=str(schedule_group.attr_arn)
)

self.schedule = scheduler.CfnSchedule(self, "MyCfnSchedule",
# name='theschedule',
group_name=schedule_group.name,
flexible_time_window=scheduler.CfnSchedule.FlexibleTimeWindowProperty(
mode="OFF",
),
state='ENABLED',
schedule_expression="rate(5 minutes)",
schedule_expression_timezone="Europe/Berlin",
target=CfnSchedule.TargetProperty(
arn=fn.function_arn,
role_arn=schedule_role.role_arn,
),
)

CfnOutput(self, 'ScheduleName',
description='The Name attribute of the schedule.',
value=str(self.schedule.ref)
)
CfnOutput(self, 'ScheduleArn',
description='The ARN of the schedule.',
value=str(self.schedule.attr_arn)
)

```

CFN

```
Resources:
Role1ABCC5F0:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Statement:
- Action: sts:AssumeRole
Effect: Allow
Principal:
Service: scheduler.amazonaws.com
Version: 2012-10-17
Description: This is a custom role...
ManagedPolicyArns:
- Fn::Join:
- ''
- - 'arn:'
- Ref: AWS::Partition
- :iam::aws:policy/AmazonEventBridgeSchedulerFullAccess
UpdateReplacePolicy: Delete
DeletionPolicy: Delete
lambdafunctionServiceRole85538ADB:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Statement:
- Action: sts:AssumeRole
Effect: Allow
Principal:
Service: lambda.amazonaws.com
Version: 2012-10-17
ManagedPolicyArns:
- Fn::Join:
- ''
- - 'arn:'
- Ref: AWS::Partition
- :iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
lambdafunction45C982D3:
Type: AWS::Lambda::Function
Properties:
Code:
ZipFile: exports.handler = handler.toString() //
Role:
Fn::GetAtt:
- lambdafunctionServiceRole85538ADB
- Arn
Handler: index.handler
Runtime: nodejs18.x
DependsOn:
- lambdafunctionServiceRole85538ADB
MyScheduleGroup:
Type: AWS::Scheduler::ScheduleGroup
Properties:
Name: GroupOfSchedules
MyCfnSchedule:
Type: AWS::Scheduler::Schedule
Properties:
FlexibleTimeWindow:
Mode: OFF
ScheduleExpression: rate(5 minutes)
Target:
Arn:
Fn::GetAtt:
- lambdafunction45C982D3
- Arn
RoleArn:
Fn::GetAtt:
- Role1ABCC5F0
- Arn
GroupName: GroupOfSchedules
ScheduleExpressionTimezone: Europe/Berlin
State: ENABLED
Outputs:
ScheduleGroupName:
Description: The Name attribute of the schedule group.
Value: GroupOfSchedules
ScheduleName:
Description: The Name attribute of the schedule.
Value:
Ref: MyCfnSchedule
ScheduleArn:
Description: The ARN of the schedule.
Value:
Fn::GetAtt:
- MyCfnSchedule
- Arn

```

### Other Details

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the supplied CDK and CloudFormation reproductions for AWS::Scheduler::ScheduleGroup and AWS::Scheduler::Schedule. Verify the stack-creation failure and investigate the reported Arn retrieval error; done means the same stack creates successfully and the Schedule Arn output resolves.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, javascript, python, yaml
Domain
cloud, infrastructure
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.