Questions tagged with DevOps

Content language: English

Sort by most recent

Browse through the questions and answers listed below or filter and sort to narrow down your results.

Update Existing Cognito User Pool Group via CDK

Hi, I have a Cognito User Pool with a user group. This simple configuration deploys fine the first time. Any subsequent attempts to run `cdk deploy` with or without changes errors out with `group already exists in stack` error. I'm using Java for my CDK Here's the code I'm using to create the user poll + group ``` public void generateStack() { // Create User Pool UserPool userPool = Builder.create(scope, "some-id") .accountRecovery(AccountRecovery.EMAIL_ONLY) .autoVerify(AutoVerifiedAttrs.builder() .email(true) .phone(false) .build()) .email(UserPoolEmail.withCognito(REPLY_TO_EMAIL)) .enableSmsRole(false) .mfa(Mfa.OFF) .passwordPolicy(PasswordPolicy.builder() .minLength(8) .requireDigits(true) .requireLowercase(true) .requireUppercase(true) .tempPasswordValidity(Duration.days(TEMP_PWD_VALIDITY_IN_DAYS)) .build()) .removalPolicy(RemovalPolicy.RETAIN) .selfSignUpEnabled(true) .signInAliases(SignInAliases.builder() .email(true) .phone(false) .preferredUsername(false) .username(false) .build()) .signInCaseSensitive(false) .standardAttributes(StandardAttributes.builder() .email(StandardAttribute.builder() .mutable(false) .required(true) .build()) .givenName(StandardAttribute.builder() .mutable(true) .required(true) .build()) .familyName(StandardAttribute.builder() .mutable(true) .required(true) .build()) .phoneNumber(StandardAttribute.builder() .mutable(true) .required(true) .build()) .build()) .userPoolName("some-pool-name") .build(); Role adminRole = Role.Builder.create(scope, "role-id") .roleName("admin-role") .assumedBy(new AccountRootPrincipal()) .description("This is a full access admin role for Ops Team") .maxSessionDuration(Duration.hours(12)) .managedPolicies(List.of(ManagedPolicy.fromAwsManagedPolicyName("AdministratorAccess"))) .build(); // Add admin group new CfnUserPoolGroup(scope, "admin-users", CfnUserPoolGroupProps.builder() .description("Admin group for the Ops team") .groupName("admin-ops") .precedence(0) .roleArn(adminRole.getRoleArn()) .userPoolId(userPool.getUserPoolId()) .build()); } ``` Is there a way to stop CDK from trying to create a group if it already exists in the stack? Thanks Kunal
0
answers
0
votes
12
views
asked 9 days ago

ASP.NET Core Application not Running in AWS Linux EC2 instance instead showing Apache Test Page

I have have an AWS CodePipeline process that gets the CodeCommit repository builds the application and publish the application to the Linux EC2 instances. The entire process executes successfully and I can see the final asp.net core application gets published to the /var/www/html/ folder. But when I get loads the URL of the load balancer (EC2 instances are behind a load balancer), I see the Apache test page, not the asp.net core application. The asp.net core application I created is just the default asp.net core web application that gets created by default. Below is the buildspec.yaml file. (This publishes a self-contained application) ``` version: 0.2 env: variables: DOTNET_CORE_RUNTIME: 6.0 phases: install: on-failure: ABORT runtime-versions: dotnet: ${DOTNET_CORE_RUNTIME} commands: - echo install stage - started `date` pre_build: commands: - echo pre build stage - stared `date` - echo restore dependencies started `date` - dotnet restore ./WebApplication1/WebApplication1.csproj build: commands: - echo build stage - started `date` - dotnet publish --configuration Release --runtime linux-x64 ./WebApplication1/WebApplication1.csproj --self-contained - cp ./WebApplication1/appspec.yml ./WebApplication1/bin/Release/net6.0/linux-x64/publish/ artifacts: files: - '**/*' - appspec.yml name: artifact-test-cham discard-paths: no base-directory: ./WebApplication1/bin/Release/net6.0/linux-x64/publish/ ``` And below is the appspec.yaml file that copies the content from the S3 artifact location to the /var/www/html/ folder ``` version: 0.0 os: linux files: - source: / destination: /var/www/html/ ``` Following image shows that the web application gets successfully published to the /var/www/html folder in the Linux EC2 instance with other asp.net core framework dependent files. But even though all the web application files along with other framework files are available, as I said, when I navigate through the load balancer, I can see the Apache test page only. ![Enter image description here](/media/postImages/original/IMrj2EksFtRkigsg3lcuTJBA) Below is the "Configure" method in the application. ``` // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.UseStatusCodePages(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapRazorPages(); }); } ``` What am I doing wrong in here? Do I have to do something from the application side? Please let me know. UPDATE: Below is the instance UserData used to in each EC2 instance. ``` #!/bin/bash -xe sudo su sudo yum -y update yum install -y ruby yum install -y aws-cli sudo amazon-linux-extras install -y php7.2 sudo yum install httpd -y sudo systemctl start httpd sudo systemctl enable httpd sudo yum install -y https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm cd /home/ec2-user # downloading & installing CodeDeploy Agent as per https://docs.aws.amazon.com/codepipeline/latest/userguide/tutorials-simple-s3.html#S3-create-instances aws s3 cp s3://aws-codedeploy-${AWS::Region}/latest/install . --region ${AWS::Region} chmod +x ./install ./install auto ```
2
answers
0
votes
65
views
champer
asked 14 days ago

Cloudformation: update stack error Service: ElastiCache, Status Code: 400

Hi, Im using cdk to to create a stack with a redis cluster ```javascript const subnets = vpc.privateSubnets.map(subnet => subnet.subnetId); const subnetGroups = new CfnSubnetGroup( this, 'redisSubnets', { description: 'redis-subnets-${environmentName}', subnetIds: subnets } ); new RedisLogs( this, 'redisClusterLogs', environmentName ); const logsDeliveryConfiguration: CfnCacheCluster.LogDeliveryConfigurationRequestProperty = { logFormat: 'json', logType: 'slow-log', destinationDetails: { cloudWatchLogsDetails: { logGroup: `/redis/${environmentName}` } }, destinationType: 'cloudwatch-logs' }; const clusterProps: CfnCacheClusterProps = { cacheNodeType: 'cache.t3.micro', engine: 'redis', numCacheNodes: 1, autoMinorVersionUpgrade: true, vpcSecurityGroupIds: [securityGroup.securityGroupId], cacheSubnetGroupName: subnetGroups.ref, clusterName: `cluster-${environmentName}`, logDeliveryConfigurations: [logsDeliveryConfiguration], engineVersion: "6.2" }; this.redisCluster = new CfnCacheCluster( this, 'redis-cluster', clusterProps ); this.redisCluster.addDependsOn(subnetGroups) ``` cloudformation fails with this error into resource redisSubnets: ``` Resource handler returned message: "No modifications were requested. (Service: ElastiCache, Status Code: 400, Request ID: xxxxxxxx)" (RequestToken: xxxxxxx, HandlerErrorCode: GeneralServiceException) ``` Im using the same code for develop, certification environments, only in test environment causes this error This stack is in a bigger stack with several nested stacks like ecs, rds and another services, curiously, redis stack not have any changes
1
answers
0
votes
38
views
asked 17 days ago