gpt4 book ai didi

amazon-web-services - Cloudformation 模板中的循环依赖

转载 作者:行者123 更新时间:2023-12-03 07:19:46 25 4
gpt4 key购买 nike

我已经在这个问题上思考了几天了。我收到 Circular dependency between resources: [ApiEcsEventsRuleProduct] 的错误我在 ApiEcsTaskDefinition 中也有循环依赖错误如果我删除 ApiEcsEventsRuleProduct共。该错误不会使调试变得明显。任何帮助将不胜感激。

AWSTemplateFormatVersion: 2010-09-09
Description: API Service ECS extensions
Parameters:
CoreStackName:
Description: The name of the API Service Core stack
Type: String
KmsKey:
Description: The ARN of the KMS configuration key
Type: String
Resources:
ApiEcsCloudwatchLogsGroup:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: !Sub "/aws/ecs/${AWS::StackName}"
RetentionInDays: 30
ApiEcsCluster:
Type: AWS::ECS::Cluster
Properties:
ClusterName: !Ref AWS::StackName
ClusterSettings:
- Name: containerInsights
Value: enabled
ApiEcsRepository:
Type: AWS::ECR::Repository
Properties:
RepositoryName: !Ref AWS::StackName
ApiEcsTaskExecutionRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Statement:
- Effect: Allow
Principal:
Service:
- ecs-tasks.amazonaws.com
Action:
- sts:AssumeRole
MaxSessionDuration: 43200
RoleName: !Ref AWS::StackName
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy
- arn:aws:iam::aws:policy/AmazonDynamoDBReadOnlyAccess
Policies:
- PolicyName: role-permissions
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action:
- kms:Decrypt
Resource: !Sub "arn:aws:kms:${AWS::Region}:${AWS::AccountId}:key/${KmsKey}"
ApiEcsTaskInstanceProfile:
Type: AWS::IAM::InstanceProfile
Properties:
Roles:
- !Ref ApiEcsTaskExecutionRole
ApiEcsTaskDefinition:
Type: AWS::ECS::TaskDefinition
Properties:
RequiresCompatibilities:
- FARGATE
Family: !Ref AWS::StackName
NetworkMode: awsvpc
Cpu: 2048
Memory: 12288
ExecutionRoleArn: !GetAtt ApiEcsTaskExecutionRole.Arn
TaskRoleArn: !GetAtt ApiEcsTaskExecutionRole.Arn
Volumes:
- Name: temp_file
ContainerDefinitions:
- Name: !Ref AWS::StackName
Cpu: 2048
Essential: true
Memory: 12288
Image: !Sub "${AWS::AccountId}.dkr.ecr.${AWS::Region}.amazonaws.com/${AWS::StackName}:latest"
LogConfiguration:
LogDriver: awslogs
Options:
awslogs-group: !Ref ApiEcsCloudwatchLogsGroup
awslogs-region: !Ref AWS::Region
awslogs-stream-prefix: ecs
MountPoints:
- SourceVolume: temp_file
ContainerPath: /var/log/exported
ApiEcsEventsRuleProduct:
Type: AWS::Events::Rule
Properties:
Name: ExportProduct
ScheduleExpression: "cron(10 3 * * ? *)"
State: DISABLED
Targets:
- Id: Canada
Arn: !Sub "arn:aws:ecs:${AWS::Region}:${AWS::AccountId}:cluster/${AWS::StackName}"
RoleArn: !Sub "arn:aws:iam::${AWS::AccountId}:role/ecsTaskExecutionRole"
Input: !Sub '{
"containerOverrides": [{
"name": "${AWS::StackName}",
"command": ["Some command"],
"environment": [{ "name": "ConfigTableName", "value": "${CoreStackName}-config" }, { "name": "JobHandlerTableName", "value": "${CoreStackName}-jobs" }, { "name": "AWS_REGION", "value": "${AWS::Region}" }]
}]
}'
EcsParameters:
LaunchType: FARGATE
TaskDefinitionArn: !Ref ApiEcsTaskDefinition
NetworkConfiguration:
AwsVpcConfiguration:
AssignPublicIp: DISABLED
SecurityGroups:
- Fn::ImportValue: !Sub "${CoreStackName}-VpcSecurityGroup"
Subnets:
- Fn::ImportValue: !Sub "${CoreStackName}-PrivateSubnet"
DependsOn:
- ApiEcsCluster
- ApiEcsRepository
- ApiEcsTaskDefinition
- ApiEcsEventsRuleProduct

最佳答案

这就是问题:

DependsOn:
- ApiEcsEventsRuleProduct

ApiEcsEventsRuleProduct 资源不能拥有对其自身的引用。

关于amazon-web-services - Cloudformation 模板中的循环依赖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73199588/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com